mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 10:28:38 -06:00
never delete instances automatically
This commit is contained in:
parent
ba39283a05
commit
4518142497
@ -10,7 +10,7 @@ import {
|
|||||||
CacheConf,
|
CacheConf,
|
||||||
ConfigService,
|
ConfigService,
|
||||||
Database,
|
Database,
|
||||||
DelInstance,
|
// DelInstance,
|
||||||
HttpServer,
|
HttpServer,
|
||||||
ProviderSession,
|
ProviderSession,
|
||||||
} from '../../config/env.config';
|
} from '../../config/env.config';
|
||||||
@ -71,28 +71,30 @@ export class WAMonitoringService {
|
|||||||
private readonly providerSession = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
private readonly providerSession = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
||||||
|
|
||||||
public delInstanceTime(instance: string) {
|
public delInstanceTime(instance: string) {
|
||||||
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
this.logger.verbose(instance);
|
||||||
if (typeof time === 'number' && time > 0) {
|
return; // Never delete instance on timeouts
|
||||||
this.logger.verbose(`Instance "${instance}" don't have connection, will be removed in ${time} minutes`);
|
// const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
||||||
|
// if (typeof time === 'number' && time > 0) {
|
||||||
|
// this.logger.verbose(`Instance "${instance}" don't have connection, will be removed in ${time} minutes`);
|
||||||
|
|
||||||
setTimeout(async () => {
|
// setTimeout(async () => {
|
||||||
if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
|
// if (this.waInstances[instance]?.connectionStatus?.state !== 'open') {
|
||||||
if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
|
// if (this.waInstances[instance]?.connectionStatus?.state === 'connecting') {
|
||||||
if ((await this.waInstances[instance].findIntegration()).integration === Integration.WHATSAPP_BAILEYS) {
|
// if ((await this.waInstances[instance].findIntegration()).integration === Integration.WHATSAPP_BAILEYS) {
|
||||||
await this.waInstances[instance]?.client?.logout('Log out instance: ' + instance);
|
// await this.waInstances[instance]?.client?.logout('Log out instance: ' + instance);
|
||||||
this.waInstances[instance]?.client?.ws?.close();
|
// this.waInstances[instance]?.client?.ws?.close();
|
||||||
this.waInstances[instance]?.client?.end(undefined);
|
// this.waInstances[instance]?.client?.end(undefined);
|
||||||
}
|
// }
|
||||||
this.waInstances[instance]?.removeRabbitmqQueues();
|
// this.waInstances[instance]?.removeRabbitmqQueues();
|
||||||
delete this.waInstances[instance];
|
// delete this.waInstances[instance];
|
||||||
} else {
|
// } else {
|
||||||
this.waInstances[instance]?.removeRabbitmqQueues();
|
// this.waInstances[instance]?.removeRabbitmqQueues();
|
||||||
delete this.waInstances[instance];
|
// delete this.waInstances[instance];
|
||||||
this.eventEmitter.emit('remove.instance', instance, 'inner');
|
// this.eventEmitter.emit('remove.instance', instance, 'inner');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 1000 * 60 * time);
|
// }, 1000 * 60 * time);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async instanceInfo(instanceName?: string, arrayReturn = false) {
|
public async instanceInfo(instanceName?: string, arrayReturn = false) {
|
||||||
@ -517,25 +519,28 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async deleteTempInstances(collections: Collection<Document>[]) {
|
private async deleteTempInstances(collections: Collection<Document>[]) {
|
||||||
const shouldDelete = this.configService.get<boolean>('DEL_TEMP_INSTANCES');
|
this.logger.verbose(collections);
|
||||||
if (!shouldDelete) {
|
return; // Never delete temp instances
|
||||||
this.logger.verbose('Temp instances deletion is disabled');
|
|
||||||
return;
|
// const shouldDelete = this.configService.get<boolean>('DEL_TEMP_INSTANCES');
|
||||||
}
|
// if (!shouldDelete) {
|
||||||
this.logger.verbose('Cleaning up temp instances');
|
// this.logger.verbose('Temp instances deletion is disabled');
|
||||||
const auths = await this.repository.auth.list();
|
// return;
|
||||||
if (auths.length === 0) {
|
// }
|
||||||
this.logger.verbose('No temp instances found');
|
// this.logger.verbose('Cleaning up temp instances');
|
||||||
return;
|
// const auths = await this.repository.auth.list();
|
||||||
}
|
// if (auths.length === 0) {
|
||||||
let tempInstances = 0;
|
// this.logger.verbose('No temp instances found');
|
||||||
auths.forEach((auth) => {
|
// return;
|
||||||
if (collections.find((coll) => coll.namespace.replace(/^[\w-]+\./, '') === auth._id)) {
|
// }
|
||||||
return;
|
// let tempInstances = 0;
|
||||||
}
|
// auths.forEach((auth) => {
|
||||||
tempInstances++;
|
// if (collections.find((coll) => coll.namespace.replace(/^[\w-]+\./, '') === auth._id)) {
|
||||||
this.eventEmitter.emit('remove.instance', auth._id, 'inner');
|
// return;
|
||||||
});
|
// }
|
||||||
this.logger.verbose('Temp instances removed: ' + tempInstances);
|
// tempInstances++;
|
||||||
|
// this.eventEmitter.emit('remove.instance', auth._id, 'inner');
|
||||||
|
// });
|
||||||
|
// this.logger.verbose('Temp instances removed: ' + tempInstances);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user