mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
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:
@@ -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);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user