Fix SingletonLock recursively via find
This commit is contained in:
parent
fc02bb1dfd
commit
a43b8e5db7
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue