[core] WEBJS - kill processes and remove Singleton

This commit is contained in:
devlikepro committed 2026-03-05 12:41:15 +07:00
1 parent 8432cd4f8d
commit 20f15b4370
1 file changed
+15
@@ -185,6 +185,9 @@ import {
WAHA_CLIENT_BROWSER_NAME,
WAHA_CLIENT_DEVICE_NAME,
} from '@waha/core/env';
import { removeSingletonFiles } from '@waha/core/utils/chrome';
import { killProcessesByPatterns } from '@waha/core/utils/processes';
import { IsChrome } from '@waha/version';
export interface WebJSConfig {
webVersion?: string;
@@ -271,6 +274,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
};
}
protected getUserDataDir(): string {
const base = process.env.WAHA_LOCAL_STORE_BASE_DIR || './.sessions';
return `${base}/webjs/default/session-${this.name}`;
}
protected async buildClient() {
const clientOptions = this.getClientOptions();
const base = process.env.WAHA_LOCAL_STORE_BASE_DIR || './.sessions';
@@ -403,6 +411,13 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
}
async start() {
await killProcessesByPatterns(
[IsChrome ? 'chrome' : 'chromium', `--a-waha-session=${this.name}`],
'SIGKILL',
this.logger,
);
await removeSingletonFiles(this.getUserDataDir());
this.status = WAHASessionStatus.STARTING;
await this.init().catch((err) => {
this.logger.error('Failed to start the client');