Skip to content

fix: run xs.stopping shutdown protocol on SIGTERM, not just SIGINT - #53

Merged
cablehead merged 3 commits into
mainfrom
service-shutdown
Aug 7, 2026
Merged

fix: run xs.stopping shutdown protocol on SIGTERM, not just SIGINT#53
cablehead merged 3 commits into
mainfrom
service-shutdown

Conversation

@cablehead

@cablehead cablehead commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Store::init spawned the service processor with tokio::spawn but dropped its JoinHandle, so nothing ever appended xs.stopping on shutdown, leaving child processes spawned by .service scripts running after SIGTERM or ctrl-c.

What changed

  • Store now keeps the service processor's JoinHandle.
  • After serve() returns, Store::shutdown appends xs.stopping and awaits that handle, bounded by a 3s timeout so a stuck processor can't hang exit.

Notes for reviewers

  • Verified locally: registered a service running ^sleep 300, sent SIGTERM to a --store --services server, and confirmed the sleep child was reaped (not reparented to pid 1) and the store recorded xs.stopping followed by xs.service.<name>.stopped.
  • cargo test passes except two pre-existing TLS tests (test_http2_tls_support, test_server_tls_socket) that fail on main too, because tests/combined.pem has expired.

cablehead added a commit to cablehead/pai-sho that referenced this pull request Aug 6, 2026
The daemon raced only ctrl_c before; nothing ran on SIGTERM, which is
what launchd/brew services/systemd/pkill send. Race the CLI socket loop
against a shutdown_signal() that selects SIGINT and SIGTERM, so a
supervisor stops the daemon cleanly and the TUN fd closes on exit (the
kernel then removes the utun and its route). Modeled on cablehead/xs#150
and cablehead/http-nu#53.
@cablehead
cablehead merged commit 38ede4f into main Aug 7, 2026
14 of 21 checks passed
@cablehead
cablehead deleted the service-shutdown branch August 7, 2026 15:01
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