mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Implemented an option to toggle temp instances deletion
This commit is contained in:
parent
499bd4328a
commit
a6adbd61db
@ -16,6 +16,7 @@ LOG_BAILEYS=error
|
|||||||
# Default time: 5 minutes
|
# Default time: 5 minutes
|
||||||
# If you don't even want an expiration, enter the value false
|
# If you don't even want an expiration, enter the value false
|
||||||
DEL_INSTANCE=false
|
DEL_INSTANCE=false
|
||||||
|
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start
|
||||||
|
|
||||||
# Temporary data storage
|
# Temporary data storage
|
||||||
STORE_MESSAGES=true
|
STORE_MESSAGES=true
|
||||||
|
@ -16,6 +16,7 @@ LOG_BAILEYS=error
|
|||||||
# Default time: 5 minutes
|
# Default time: 5 minutes
|
||||||
# If you don't even want an expiration, enter the value false
|
# If you don't even want an expiration, enter the value false
|
||||||
DEL_INSTANCE=false
|
DEL_INSTANCE=false
|
||||||
|
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start
|
||||||
|
|
||||||
# Temporary data storage
|
# Temporary data storage
|
||||||
STORE_MESSAGES=true
|
STORE_MESSAGES=true
|
||||||
|
@ -35,6 +35,7 @@ ENV LOG_COLOR=true
|
|||||||
ENV LOG_BAILEYS=error
|
ENV LOG_BAILEYS=error
|
||||||
|
|
||||||
ENV DEL_INSTANCE=false
|
ENV DEL_INSTANCE=false
|
||||||
|
ENV DEL_TEMP_INSTANCES=true
|
||||||
|
|
||||||
ENV STORE_MESSAGES=true
|
ENV STORE_MESSAGES=true
|
||||||
ENV STORE_MESSAGE_UP=true
|
ENV STORE_MESSAGE_UP=true
|
||||||
|
@ -189,6 +189,7 @@ export interface Env {
|
|||||||
WA_BUSINESS: WaBusiness;
|
WA_BUSINESS: WaBusiness;
|
||||||
LOG: Log;
|
LOG: Log;
|
||||||
DEL_INSTANCE: DelInstance;
|
DEL_INSTANCE: DelInstance;
|
||||||
|
DEL_TEMP_INSTANCES: boolean;
|
||||||
LANGUAGE: Language;
|
LANGUAGE: Language;
|
||||||
WEBHOOK: Webhook;
|
WEBHOOK: Webhook;
|
||||||
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
||||||
@ -317,6 +318,9 @@ export class ConfigService {
|
|||||||
DEL_INSTANCE: isBooleanString(process.env?.DEL_INSTANCE)
|
DEL_INSTANCE: isBooleanString(process.env?.DEL_INSTANCE)
|
||||||
? process.env.DEL_INSTANCE === 'true'
|
? process.env.DEL_INSTANCE === 'true'
|
||||||
: Number.parseInt(process.env.DEL_INSTANCE) || false,
|
: Number.parseInt(process.env.DEL_INSTANCE) || false,
|
||||||
|
DEL_TEMP_INSTANCES: isBooleanString(process.env?.DEL_TEMP_INSTANCES)
|
||||||
|
? process.env.DEL_TEMP_INSTANCES === 'true'
|
||||||
|
: true,
|
||||||
LANGUAGE: process.env?.LANGUAGE || 'en',
|
LANGUAGE: process.env?.LANGUAGE || 'en',
|
||||||
WEBHOOK: {
|
WEBHOOK: {
|
||||||
GLOBAL: {
|
GLOBAL: {
|
||||||
|
@ -47,6 +47,7 @@ LOG:
|
|||||||
# Default time: 5 minutes
|
# Default time: 5 minutes
|
||||||
# If you don't even want an expiration, enter the value false
|
# If you don't even want an expiration, enter the value false
|
||||||
DEL_INSTANCE: false # or false
|
DEL_INSTANCE: false # or false
|
||||||
|
DEL_TEMP_INSTANCES: true # Delete instances with status closed on start
|
||||||
|
|
||||||
# Temporary data storage
|
# Temporary data storage
|
||||||
STORE:
|
STORE:
|
||||||
|
@ -480,6 +480,11 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async deleteTempInstances(collections: Collection<Document>[]) {
|
private async deleteTempInstances(collections: Collection<Document>[]) {
|
||||||
|
const shouldDelete = this.configService.get<boolean>('DEL_TEMP_INSTANCES');
|
||||||
|
if (!shouldDelete) {
|
||||||
|
this.logger.verbose('Temp instances deletion is disabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.logger.verbose('Cleaning up temp instances');
|
this.logger.verbose('Cleaning up temp instances');
|
||||||
const auths = await this.repository.auth.list();
|
const auths = await this.repository.auth.list();
|
||||||
if (auths.length === 0) {
|
if (auths.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user