-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move nomos-utils/lifecycle.rs.rs->nomos-services/utils'
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use overwatch_rs::services::life_cycle::LifecycleMessage; | ||
use overwatch_rs::services::ServiceData; | ||
use tracing::{debug, error}; | ||
|
||
/// Handles the shutdown signal from `Overwatch` | ||
pub async fn should_stop_service<S: ServiceData>(msg: &LifecycleMessage) -> bool { | ||
match msg { | ||
LifecycleMessage::Shutdown(sender) => { | ||
if sender.send(()).is_err() { | ||
error!( | ||
"Error sending successful shutdown signal from service {}", | ||
S::SERVICE_ID | ||
); | ||
} | ||
debug!("{} {}", S::SERVICE_ID, "Shutting down service"); | ||
true | ||
} | ||
LifecycleMessage::Kill => { | ||
debug!("{} {}", S::SERVICE_ID, "Killing service"); | ||
true | ||
} | ||
} | ||
} |