Skip to content

Commit a6adbd6

Browse files
committed
Implemented an option to toggle temp instances deletion
1 parent 499bd43 commit a6adbd6

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

Docker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LOG_BAILEYS=error
1616
# Default time: 5 minutes
1717
# If you don't even want an expiration, enter the value false
1818
DEL_INSTANCE=false
19+
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start
1920

2021
# Temporary data storage
2122
STORE_MESSAGES=true

Docker/evolution-api-all-services/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LOG_BAILEYS=error
1616
# Default time: 5 minutes
1717
# If you don't even want an expiration, enter the value false
1818
DEL_INSTANCE=false
19+
DEL_TEMP_INSTANCES=true # Delete instances with status closed on start
1920

2021
# Temporary data storage
2122
STORE_MESSAGES=true

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ENV LOG_COLOR=true
3535
ENV LOG_BAILEYS=error
3636

3737
ENV DEL_INSTANCE=false
38+
ENV DEL_TEMP_INSTANCES=true
3839

3940
ENV STORE_MESSAGES=true
4041
ENV STORE_MESSAGE_UP=true

src/config/env.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export interface Env {
189189
WA_BUSINESS: WaBusiness;
190190
LOG: Log;
191191
DEL_INSTANCE: DelInstance;
192+
DEL_TEMP_INSTANCES: boolean;
192193
LANGUAGE: Language;
193194
WEBHOOK: Webhook;
194195
CONFIG_SESSION_PHONE: ConfigSessionPhone;
@@ -317,6 +318,9 @@ export class ConfigService {
317318
DEL_INSTANCE: isBooleanString(process.env?.DEL_INSTANCE)
318319
? process.env.DEL_INSTANCE === 'true'
319320
: Number.parseInt(process.env.DEL_INSTANCE) || false,
321+
DEL_TEMP_INSTANCES: isBooleanString(process.env?.DEL_TEMP_INSTANCES)
322+
? process.env.DEL_TEMP_INSTANCES === 'true'
323+
: true,
320324
LANGUAGE: process.env?.LANGUAGE || 'en',
321325
WEBHOOK: {
322326
GLOBAL: {

src/dev-env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ LOG:
4747
# Default time: 5 minutes
4848
# If you don't even want an expiration, enter the value false
4949
DEL_INSTANCE: false # or false
50+
DEL_TEMP_INSTANCES: true # Delete instances with status closed on start
5051

5152
# Temporary data storage
5253
STORE:

src/whatsapp/services/monitor.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ export class WAMonitoringService {
480480
}
481481

482482
private async deleteTempInstances(collections: Collection<Document>[]) {
483+
const shouldDelete = this.configService.get<boolean>('DEL_TEMP_INSTANCES');
484+
if (!shouldDelete) {
485+
this.logger.verbose('Temp instances deletion is disabled');
486+
return;
487+
}
483488
this.logger.verbose('Cleaning up temp instances');
484489
const auths = await this.repository.auth.list();
485490
if (auths.length === 0) {

0 commit comments

Comments
 (0)