Skip to content

Commit deb92b9

Browse files
committed
Properly handle SIGTERM and SIGINT
Fixes issue where killing the server when deployed doesn't work too well
1 parent c81506b commit deb92b9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/serve.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ export const ServeCommand = cmd({
2525
hostname,
2626
})
2727
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
28+
29+
const stop = async () => {
30+
console.log("stopping server...")
31+
await server.stop()
32+
process.exit(0)
33+
}
34+
35+
process.on("SIGTERM", stop)
36+
process.on("SIGINT", stop)
37+
2838
await new Promise(() => {})
29-
await server.stop()
3039
},
3140
})

0 commit comments

Comments
 (0)