MCPcopy
hub / github.com/garrytan/gstack / teardownAndExit

Function teardownAndExit

browse/src/cli.ts:1172–1181  ·  view source on GitHub ↗
(signal: string)

Source from the content-addressed store, hash-verified

1170 console.log('[browse] Supervisor mode: monitoring server. Ctrl-C to stop.');
1171 let supervisorExiting = false;
1172 const teardownAndExit = (signal: string) => {
1173 if (supervisorExiting) return;
1174 supervisorExiting = true;
1175 console.log(`\n[browse] ${signal} received — stopping server.`);
1176 const state = readState();
1177 if (state?.pid && isProcessAlive(state.pid)) {
1178 safeKill(state.pid, 'SIGTERM');
1179 }
1180 process.exit(0);
1181 };
1182 process.on('SIGINT', () => teardownAndExit('SIGINT'));
1183 process.on('SIGTERM', () => teardownAndExit('SIGTERM'));
1184

Callers 1

mainFunction · 0.85

Calls 3

isProcessAliveFunction · 0.90
safeKillFunction · 0.90
readStateFunction · 0.70

Tested by

no test coverage detected