fix(lifecycle): use ProcessLifecycle for coordinated shutdown
Replace per-Watcher SIGINT handlers with a single ProcessLifecycle.install() in TsWatch.start(). This eliminates competing signal handler races that left orphaned child processes. Add @push.rocks/smartexit as direct dependency.
This commit is contained in:
@@ -46,6 +46,14 @@ export class TsWatch {
|
||||
public async start() {
|
||||
logger.log('info', 'Starting tswatch with config-driven mode');
|
||||
|
||||
// Install global process lifecycle handlers (SIGINT, SIGTERM, etc.)
|
||||
// This is the single authority for signal handling — no per-watcher handlers.
|
||||
plugins.smartexit.ProcessLifecycle.install();
|
||||
const exitInstance = new plugins.smartexit.SmartExit({ silent: true });
|
||||
exitInstance.addCleanupFunction(async () => {
|
||||
await this.stop();
|
||||
});
|
||||
|
||||
// Start server if configured
|
||||
if (this.config.server?.enabled) {
|
||||
await this.startServer();
|
||||
|
||||
Reference in New Issue
Block a user