Remove unnecessary shutdown handlers
Daemon runs forever; launchd manages lifecycle. SQLite handles ungraceful shutdowns fine. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,10 +32,6 @@ export function initDatabase(): void {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeDatabase(): void {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function storeMessage(msg: proto.IWebMessageInfo, chatJid: string, isFromMe: boolean): void {
|
export function storeMessage(msg: proto.IWebMessageInfo, chatJid: string, isFromMe: boolean): void {
|
||||||
if (!msg.key) return;
|
if (!msg.key) return;
|
||||||
|
|
||||||
|
|||||||
10
src/index.ts
10
src/index.ts
@@ -20,7 +20,7 @@ import {
|
|||||||
CLEAR_COMMAND
|
CLEAR_COMMAND
|
||||||
} from './config.js';
|
} from './config.js';
|
||||||
import { RegisteredGroup, Session, NewMessage } from './types.js';
|
import { RegisteredGroup, Session, NewMessage } from './types.js';
|
||||||
import { initDatabase, closeDatabase, storeMessage, getNewMessages } from './db.js';
|
import { initDatabase, storeMessage, getNewMessages } from './db.js';
|
||||||
|
|
||||||
const logger = pino({
|
const logger = pino({
|
||||||
level: process.env.LOG_LEVEL || 'info',
|
level: process.env.LOG_LEVEL || 'info',
|
||||||
@@ -232,14 +232,6 @@ async function main(): Promise<void> {
|
|||||||
logger.info('Database initialized');
|
logger.info('Database initialized');
|
||||||
loadState();
|
loadState();
|
||||||
await connectWhatsApp();
|
await connectWhatsApp();
|
||||||
|
|
||||||
const shutdown = () => {
|
|
||||||
logger.info('Shutting down...');
|
|
||||||
closeDatabase();
|
|
||||||
process.exit(0);
|
|
||||||
};
|
|
||||||
process.on('SIGINT', shutdown);
|
|
||||||
process.on('SIGTERM', shutdown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
|
|||||||
Reference in New Issue
Block a user