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:
手瓜一十雪 committed 2026-01-18 12:10:14 +08:00
1 parent d80e6ae2e0
commit b9f1c16634
2 files changed
+47 -54

No files matched your search

+9
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);
},
};
}