From a43b8e5db767eaa1bac48d9e619df5a94e7134f7 Mon Sep 17 00:00:00 2001 From: Deep Koluguri Date: Fri, 19 Jun 2026 16:15:00 -0400 Subject: [PATCH] Fix SingletonLock recursively via find --- whatsapp-gateway/server.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/whatsapp-gateway/server.js b/whatsapp-gateway/server.js index d5a11b1..272e2a1 100644 --- a/whatsapp-gateway/server.js +++ b/whatsapp-gateway/server.js @@ -25,19 +25,13 @@ app.use(express.static(path.join(__dirname, 'public'))); // Initialize WhatsApp Web Client with LocalAuth to persist session function removeSingletonLock() { try { - const authPath = path.join(__dirname, '.wwebjs_auth'); - if (require('fs').existsSync(authPath)) { - const sessions = require('fs').readdirSync(authPath); - for (const session of sessions) { - const lockPath = path.join(authPath, session, 'SingletonLock'); - if (require('fs').existsSync(lockPath)) { - require('fs').unlinkSync(lockPath); - console.log(`[WhatsApp Bot] Removed stale SingletonLock at ${lockPath}`); - } - } - } + const authPath = require('path').join(__dirname, '.wwebjs_auth'); + require('child_process').execSync(`find ${authPath} -name "SingletonLock" -delete`); + require('child_process').execSync(`find ${authPath} -name "SingletonCookie" -delete`); + require('child_process').execSync(`find ${authPath} -name "SingletonSocket" -delete`); + console.log('[WhatsApp Bot] Cleaned up Chromium locks recursively.'); } catch (err) { - console.error('[WhatsApp Bot] Error removing SingletonLock:', err); + console.error('[WhatsApp Bot] Error removing Chromium locks:', err); } } removeSingletonLock();