Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/cli/dev/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class ProcessManager implements IProcessManager {
// Spawn tsx watch with the user's entrypoint
this.process = spawn(process.execPath, [tsxCli, ...args], {
cwd: process.cwd(),
detached: true,
env: {
...process.env,
AWS_LAMBDA_RUNTIME_API: this.runtimeApiUrl,
Expand Down Expand Up @@ -179,7 +180,11 @@ export class ProcessManager implements IProcessManager {
const killTimeout = setTimeout(() => {
if (this.process) {
console.log(chalk.yellow("⚠️ Force killing runtime process"));
this.process.kill("SIGKILL");
try {
process.kill(-this.process.pid!, "SIGKILL");
} catch {
this.process.kill("SIGKILL");
}
}
}, 5000);

Expand All @@ -190,8 +195,14 @@ export class ProcessManager implements IProcessManager {
resolve();
});

// Try graceful shutdown first
this.process.kill("SIGTERM");
// Kill the entire process group (negative PID) so tsx watch's
// children are also cleaned up. Falls back to direct kill if
// the process group kill fails.
try {
process.kill(-this.process.pid!, "SIGTERM");
} catch {
this.process.kill("SIGTERM");
}
});
}

Expand Down