Skip to content

feat(daemon): add SIGUSR1 graceful exit and SIGUSR2 progress dump signals - #2494

Merged
oferchen merged 1 commit into
masterfrom
feat/signal-handlers
Feb 26, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/signal-handlers

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add SIGUSR1 handler that sets a graceful_exit flag, causing the daemon to stop accepting new connections and drain active workers before exiting cleanly (mirrors upstream rsync's RERR_SIGNAL1 / exit code 19 behavior)
  • Add SIGUSR2 handler that sets a progress_dump flag, causing the daemon to log a summary of active connections, total connections served, and daemon uptime on the next loop iteration (mirrors upstream rsync's SIGUSR2 statistics dump)
  • Wire both flags into single-listener and multi-listener (dual-stack) accept loops, sharing graceful_exit with acceptor threads for prompt shutdown
  • All signal handling remains gated with #[cfg(unix)]; non-Unix platforms get no-op defaults

Test plan

  • cargo fmt -p daemon -- --check passes
  • cargo clippy -p daemon --all-targets --all-features --no-deps -- -D warnings passes
  • cargo nextest run -p daemon passes (843 tests)
  • CI checks (fmt+clippy, nextest, Windows, macOS, Linux musl)
  • Manual verification: start daemon, send kill -USR1 <pid> and verify graceful drain
  • Manual verification: start daemon, send kill -USR2 <pid> and verify progress log output

…nals

Register SIGUSR1 and SIGUSR2 handlers in the daemon signal framework
using the existing signal-hook crate. SIGUSR1 sets a graceful_exit flag
that stops accepting new connections and drains active workers before
exit, mirroring upstream rsync's RERR_SIGNAL1 behavior. SIGUSR2 sets a
progress_dump flag that logs active connections, total served, and
uptime on the next loop iteration.

Both flags are wired into the single-listener and multi-listener
(dual-stack) accept loops. The graceful_exit flag is also shared with
acceptor threads so they stop promptly. All signal handling is gated
with #[cfg(unix)] as before.
@github-actions github-actions Bot added the enhancement New feature or request label Feb 26, 2026
@oferchen
oferchen merged commit 23e4a6e into master Feb 26, 2026
31 checks passed
@oferchen
oferchen deleted the feat/signal-handlers branch February 26, 2026 13:23
oferchen added a commit that referenced this pull request May 1, 2026
…nals (#2494)

Register SIGUSR1 and SIGUSR2 handlers in the daemon signal framework
using the existing signal-hook crate. SIGUSR1 sets a graceful_exit flag
that stops accepting new connections and drains active workers before
exit, mirroring upstream rsync's RERR_SIGNAL1 behavior. SIGUSR2 sets a
progress_dump flag that logs active connections, total served, and
uptime on the next loop iteration.

Both flags are wired into the single-listener and multi-listener
(dual-stack) accept loops. The graceful_exit flag is also shared with
acceptor threads so they stop promptly. All signal handling is gated
with #[cfg(unix)] as before.
oferchen added a commit that referenced this pull request May 5, 2026
…nals (#2494)

Register SIGUSR1 and SIGUSR2 handlers in the daemon signal framework
using the existing signal-hook crate. SIGUSR1 sets a graceful_exit flag
that stops accepting new connections and drains active workers before
exit, mirroring upstream rsync's RERR_SIGNAL1 behavior. SIGUSR2 sets a
progress_dump flag that logs active connections, total served, and
uptime on the next loop iteration.

Both flags are wired into the single-listener and multi-listener
(dual-stack) accept loops. The graceful_exit flag is also shared with
acceptor threads so they stop promptly. All signal handling is gated
with #[cfg(unix)] as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant