Skip to content

Commit 88de377

Browse files
committed
Rename ShutdownManager to LifecycleManager
1 parent 0b7042b commit 88de377

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

crates/cli/src/commands/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use tracing::{info, info_span, warn, Instrument};
2424

2525
use crate::{
2626
app_state::AppState,
27-
shutdown::ShutdownManager,
27+
lifecycle::LifecycleManager,
2828
util::{
2929
database_pool_from_config, mailer_from_config, password_manager_from_config,
3030
policy_factory_from_config, site_config_from_config, templates_from_config,
@@ -56,7 +56,7 @@ impl Options {
5656
#[allow(clippy::too_many_lines)]
5757
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
5858
let span = info_span!("cli.run.init").entered();
59-
let mut shutdown = ShutdownManager::new()?;
59+
let mut shutdown = LifecycleManager::new()?;
6060
let config = AppConfig::extract(figment)?;
6161

6262
info!(version = crate::VERSION, "Starting up");

crates/cli/src/commands/worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use mas_router::UrlBuilder;
1414
use tracing::{info, info_span};
1515

1616
use crate::{
17-
shutdown::ShutdownManager,
17+
lifecycle::LifecycleManager,
1818
util::{
1919
database_pool_from_config, mailer_from_config, site_config_from_config,
2020
templates_from_config,
@@ -26,7 +26,7 @@ pub(super) struct Options {}
2626

2727
impl Options {
2828
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
29-
let shutdown = ShutdownManager::new()?;
29+
let shutdown = LifecycleManager::new()?;
3030
let span = info_span!("cli.worker.init").entered();
3131
let config = AppConfig::extract(figment)?;
3232

crates/cli/src/shutdown.rs renamed to crates/cli/src/lifecycle.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use mas_templates::Templates;
1111
use tokio::signal::unix::{Signal, SignalKind};
1212
use tokio_util::{sync::CancellationToken, task::TaskTracker};
1313

14-
/// A helper to manage graceful shutdowns and track tasks that gracefully
15-
/// shutdown.
14+
/// A helper to manage the lifecycle of the service, inclusing handling graceful
15+
/// shutdowns and configuration reloads.
1616
///
1717
/// It will listen for SIGTERM and SIGINT signals, and will trigger a soft
1818
/// shutdown on the first signal, and a hard shutdown on the second signal or
@@ -25,7 +25,10 @@ use tokio_util::{sync::CancellationToken, task::TaskTracker};
2525
///
2626
/// They should also use the `task_tracker` to make it track things running, so
2727
/// that it knows when the soft shutdown is over and worked.
28-
pub struct ShutdownManager {
28+
///
29+
/// It also integrates with [`sd_notify`] to notify the service manager of the
30+
/// state of the service.
31+
pub struct LifecycleManager {
2932
hard_shutdown_token: CancellationToken,
3033
soft_shutdown_token: CancellationToken,
3134
task_tracker: TaskTracker,
@@ -68,7 +71,7 @@ fn notify(states: &[sd_notify::NotifyState]) {
6871
}
6972
}
7073

71-
impl ShutdownManager {
74+
impl LifecycleManager {
7275
/// Create a new shutdown manager, installing the signal handlers
7376
///
7477
/// # Errors

crates/cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use tracing_subscriber::{
1818

1919
mod app_state;
2020
mod commands;
21+
mod lifecycle;
2122
mod server;
22-
mod shutdown;
2323
mod sync;
2424
mod telemetry;
2525
mod util;

0 commit comments

Comments
 (0)