Add opt-in DISABLE_SIGNALS to ignore shutdown signals#667
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Unix signal handler now respects a ChangesSelective Signal Disabling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/common.rs (1)
280-299: ⚡ Quick winAdd coverage for
sig-prefixed tokens.
parse_disabled_signals()supports optionalsigprefixes, but current tests don’t assert that behavior. Add cases likesigint,sighup, and mixed forms to lock this contract.Suggested test additions
#[test] fn parse_signals() { assert_eq!(parse_disabled_signals(""), DisabledSignals::default()); @@ assert_eq!( parse_disabled_signals("bogus,quit"), DisabledSignals { quit: true, ..Default::default() } ); + assert_eq!( + parse_disabled_signals("sigint,sighup"), + DisabledSignals { int: true, hup: true, ..Default::default() } + ); + assert_eq!( + parse_disabled_signals("SIGQUIT,sigterm"), + DisabledSignals { quit: true, term: true, ..Default::default() } + ); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/common.rs` around lines 280 - 299, Update the parse_signals unit test to cover the optional "sig" prefix support: add assertions that parse_disabled_signals("sigint") yields DisabledSignals { int: true, ..Default::default() }, parse_disabled_signals("sighup") yields DisabledSignals { hup: true, ..Default::default() }, and include a mixed-case/whitespace example such as parse_disabled_signals(" SIGTERM , sigquit ") or parse_disabled_signals("sigint,quit") to ensure parse_disabled_signals and the DisabledSignals behavior handle "sig"-prefixed tokens and mixed forms correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/common.rs`:
- Around line 207-211: The ignore closure currently swallows errors from
signal(kind); update it to log failures when signal(kind) returns Err (e.g.,
with log::error or log::warn) so misconfiguration is visible: replace the if let
Ok(mut s) = signal(kind) branch with a match or an else that logs the returned
error (including the signal name and error), and keep the existing tokio::spawn
loop behavior in the Ok arm unchanged.
---
Nitpick comments:
In `@src/common.rs`:
- Around line 280-299: Update the parse_signals unit test to cover the optional
"sig" prefix support: add assertions that parse_disabled_signals("sigint")
yields DisabledSignals { int: true, ..Default::default() },
parse_disabled_signals("sighup") yields DisabledSignals { hup: true,
..Default::default() }, and include a mixed-case/whitespace example such as
parse_disabled_signals(" SIGTERM , sigquit ") or
parse_disabled_signals("sigint,quit") to ensure parse_disabled_signals and the
DisabledSignals behavior handle "sig"-prefixed tokens and mixed forms correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Closes #199
Adds an opt-in
DISABLE_SIGNALSenv var so hbbs/hbbr can ignore shutdown signals on hosts without a process supervisor. Accepts a comma separated list ofhup,term,int,quitorall. A listed signal is caught and swallowed instead of triggering a shutdown.DISABLE_SIGNALS=hupis enough to survive an ssh logout without nohup.setsidor a supervisor is still the better path, but this helps if neither are available.Summary by CodeRabbit
New Features
Tests