Skip to content

Commit

Permalink
fix: make graceful daemon shutdown exit with code 0
Browse files Browse the repository at this point in the history
When shutting down pueued using SIGINT or SIGTERM then the exit code
should be zero. This is necessary, for example, when running as a
systemd service since systemd will otherwise put the service in a
failed state whenever it shuts down.
  • Loading branch information
rycee committed Mar 5, 2024
1 parent 6fd3f7c commit a355e72
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Fix reading of configuration files that lacks a `shared` section.

- Made the daemon exit gracefully (exit code 0) on SIGINT and SIGTEM.

## [3.3.3] - 2024-01-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pueue/src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn setup_signal_panic_handling(settings: &Settings, sender: &TaskSender) -> Resu
ctrlc::set_handler(move || {
// Notify the task handler
sender_clone
.send(Shutdown::Emergency)
.send(Shutdown::Graceful)
.expect("Failed to send Message to TaskHandler on Shutdown");
})?;

Expand Down
2 changes: 1 addition & 1 deletion pueue/tests/daemon/integration/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn test_ctrlc() -> Result<()> {
let result = child.try_wait();
assert!(matches!(result, Ok(Some(_))));
let code = result.unwrap().unwrap();
assert!(matches!(code.code(), Some(1)));
assert!(matches!(code.code(), Some(0)));

Ok(())
}
Expand Down

0 comments on commit a355e72

Please # to comment.