Use case
Every HTTP/cluster example hand-rolls the same shutdown choreography: process.on('SIGINT', ...) -> server.unbind() -> cluster.leave() -> system.terminate() — even though CoordinatedShutdown exists with phase-ordered shutdown. Users copy this boilerplate into production apps, usually getting the ordering or double-signal handling subtly wrong.
Proposed API
const server = await system.http(port).bind(routes); // registers unbind in the service-unbind phase automatically
await system.runUntilTerminated(); // installs SIGINT/SIGTERM handlers -> CoordinatedShutdown.run()
- HTTP bind and broker actors register their teardown in the appropriate
CoordinatedShutdown phase on creation (opt-out via options).
runUntilTerminated() (name open) resolves when the system has fully terminated; signal handlers are removed afterwards.
- Cross-runtime: signal handling goes through
src/runtime/ (Bun/Node/Deno differences).
Acceptance criteria
Related
Use case
Every HTTP/cluster example hand-rolls the same shutdown choreography:
process.on('SIGINT', ...)->server.unbind()->cluster.leave()->system.terminate()— even thoughCoordinatedShutdownexists with phase-ordered shutdown. Users copy this boilerplate into production apps, usually getting the ordering or double-signal handling subtly wrong.Proposed API
CoordinatedShutdownphase on creation (opt-out via options).runUntilTerminated()(name open) resolves when the system has fully terminated; signal handlers are removed afterwards.src/runtime/(Bun/Node/Deno differences).Acceptance criteria
Related