Skip to content

fix: serve Ctrl-C stop#38

Open
zkd-11 wants to merge 1 commit into
tamnd:mainfrom
zkd-11:fix-serve-signal
Open

fix: serve Ctrl-C stop#38
zkd-11 wants to merge 1 commit into
tamnd:mainfrom
zkd-11:fix-serve-signal

Conversation

@zkd-11

@zkd-11 zkd-11 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

This PR fixes shutdown handling for the kage serve command:

  • Handles both SIGINT and SIGTERM so the running server can be stopped cleanly.
  • Shuts down the HTTP server on cancellation so the listening port is released.

Details

Previously, kage serve could print press Ctrl-C to stop, but pressing Ctrl+C did not reliably terminate the process in some terminal environments. The process could keep running and continue holding port 8800.

This change updates the CLI entrypoint to listen for both os.Interrupt and syscall.SIGTERM. Once the first signal is received, it restores the default signal behavior so a second Ctrl+C can force termination.

The serve command now shuts down its HTTP server through http.Server.Shutdown with a short timeout, falling back to Close if graceful shutdown fails. This releases the listening port after cancellation.

Testing

go test ./...
go build -o ./bin/kage ./cmd/kage
./bin/kage serve .

Manual checks:

  • Ctrl+C stops kage serve.
  • Port 8800 is released after shutdown.
  • Sending SIGTERM also stops the server cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant