Skip to content

Commit

Permalink
refactor: move nomos-utils/lifecycle.rs.rs->nomos-services/utils'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrussal committed Feb 18, 2025
1 parent 349e06d commit 1dc6606
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions nomos-services/utils/src/overwatch/lifecycle.rs
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
}
}
}

0 comments on commit 1dc6606

Please sign in to comment.