Refactor process management and improve shutdown logic

Removed excessive logging and streamlined process restart and shutdown flows in napcat.ts. Added isShuttingDown flag to prevent unintended worker restarts during shutdown. Improved forceKillProcess to handle Windows-specific process termination. Updated IWorkerProcess interface and implementations to include the 'off' event method for better event management.
This commit is contained in:
手瓜一十雪
2026-01-18 12:10:14 +08:00
parent d80e6ae2e0
commit b9f1c16634
2 changed files with 47 additions and 54 deletions

View File

@@ -25,6 +25,7 @@ export interface IWorkerProcess {
kill (): boolean;
on (event: string, listener: (...args: unknown[]) => void): void;
once (event: string, listener: (...args: unknown[]) => void): void;
off (event: string, listener: (...args: unknown[]) => void): void;
}
/**
@@ -79,6 +80,10 @@ class ElectronProcessManager implements IProcessManager {
once (event: string, listener: (...args: unknown[]) => void): void {
child.once(event, listener);
},
off (event: string, listener: (...args: unknown[]) => void): void {
child.off(event, listener);
},
};
}
@@ -134,6 +139,10 @@ class NodeProcessManager implements IProcessManager {
once (event: string, listener: (...args: unknown[]) => void): void {
child.once(event, listener);
},
off (event: string, listener: (...args: unknown[]) => void): void {
child.off(event, listener);
},
};
}