Fix SingletonLock issue on restart
This commit is contained in:
parent
a75fcfd67d
commit
fc02bb1dfd
|
|
@ -23,6 +23,25 @@ app.use(express.json());
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
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() {
|
||||||
|
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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[WhatsApp Bot] Error removing SingletonLock:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeSingletonLock();
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
authStrategy: new LocalAuth({
|
authStrategy: new LocalAuth({
|
||||||
dataPath: './.wwebjs_auth'
|
dataPath: './.wwebjs_auth'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue