fixed shutdown not working sometimes

This commit is contained in:
Boki 2025-06-20 18:42:16 -04:00
parent 18c2720fe8
commit 9065937d2c

View file

@ -172,11 +172,13 @@ export class Shutdown {
process.platform === 'win32' ? ['SIGINT', 'SIGTERM'] : ['SIGTERM', 'SIGINT', 'SIGUSR2'];
signals.forEach(signal => {
process.once(signal, () => {
// Changed from 'on' to 'once' to prevent multiple handlers
this.shutdownAndExit(signal).catch(() => {
process.exit(1);
});
process.on(signal, () => {
// Only process if not already shutting down
if (!this.isShuttingDown) {
this.shutdownAndExit(signal).catch(() => {
process.exit(1);
});
}
});
});