Fix SingletonLock recursively via find

This commit is contained in:
Deep Koluguri 2026-06-19 16:15:00 -04:00
parent fc02bb1dfd
commit a43b8e5db7
1 changed files with 6 additions and 12 deletions

View File

@ -25,19 +25,13 @@ app.use(express.static(path.join(__dirname, 'public')));
// Initialize WhatsApp Web Client with LocalAuth to persist session // Initialize WhatsApp Web Client with LocalAuth to persist session
function removeSingletonLock() { function removeSingletonLock() {
try { try {
const authPath = path.join(__dirname, '.wwebjs_auth'); const authPath = require('path').join(__dirname, '.wwebjs_auth');
if (require('fs').existsSync(authPath)) { require('child_process').execSync(`find ${authPath} -name "SingletonLock" -delete`);
const sessions = require('fs').readdirSync(authPath); require('child_process').execSync(`find ${authPath} -name "SingletonCookie" -delete`);
for (const session of sessions) { require('child_process').execSync(`find ${authPath} -name "SingletonSocket" -delete`);
const lockPath = path.join(authPath, session, 'SingletonLock'); console.log('[WhatsApp Bot] Cleaned up Chromium locks recursively.');
if (require('fs').existsSync(lockPath)) {
require('fs').unlinkSync(lockPath);
console.log(`[WhatsApp Bot] Removed stale SingletonLock at ${lockPath}`);
}
}
}
} catch (err) { } catch (err) {
console.error('[WhatsApp Bot] Error removing SingletonLock:', err); console.error('[WhatsApp Bot] Error removing Chromium locks:', err);
} }
} }
removeSingletonLock(); removeSingletonLock();