mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 02:14:32 +00:00
fix(cursor): kill orphaned daemon on timeout and fix exit codes
MEDIUM fixes: - Kill orphaned process when health check times out after 30s - Prevents zombie processes from consuming resources LOW fixes: - Return exit code 1 for unknown cursor subcommands (was 0) - Simplify exit handler dead code branch (else if code !== null → else)
This commit is contained in:
1 parent
7d4e6d6b65
commit
88ad13ee7b
2 files changed
+11
-2
No files matched your search
@@ -48,7 +48,8 @@ export async function handleCursorCommand(args: string[]): Promise<number> {
|
|||||||
default:
|
default:
|
||||||
console.error(fail(`Unknown subcommand: ${subcommand}`));
|
console.error(fail(`Unknown subcommand: ${subcommand}`));
|
||||||
console.error('');
|
console.error('');
|
||||||
return handleHelp();
|
handleHelp();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,14 @@ export async function startDaemon(
|
|||||||
if (await isDaemonRunning(config.port)) {
|
if (await isDaemonRunning(config.port)) {
|
||||||
safeResolve({ success: true, pid: proc.pid });
|
safeResolve({ success: true, pid: proc.pid });
|
||||||
} else if (attempts >= maxAttempts) {
|
} else if (attempts >= maxAttempts) {
|
||||||
|
// Kill orphaned process
|
||||||
|
if (proc.pid) {
|
||||||
|
try {
|
||||||
|
process.kill(proc.pid, 'SIGTERM');
|
||||||
|
} catch {
|
||||||
|
/* already dead */
|
||||||
|
}
|
||||||
|
}
|
||||||
safeResolve({
|
safeResolve({
|
||||||
success: false,
|
success: false,
|
||||||
error: 'Daemon did not start within 30 seconds',
|
error: 'Daemon did not start within 30 seconds',
|
||||||
@@ -230,7 +238,7 @@ export async function startDaemon(
|
|||||||
success: false,
|
success: false,
|
||||||
error: 'Daemon process exited unexpectedly with code 0',
|
error: 'Daemon process exited unexpectedly with code 0',
|
||||||
});
|
});
|
||||||
} else if (code !== null) {
|
} else {
|
||||||
safeResolve({
|
safeResolve({
|
||||||
success: false,
|
success: false,
|
||||||
error: `Daemon process exited with code ${code}`,
|
error: `Daemon process exited with code ${code}`,
|
||||||
|
|||||||
Reference in new issue
Block a user