Skip to main content

micromegas/
config.rs

1//! CLI args shared by every long-running server binary.
2
3use std::time::Duration;
4
5/// CLI args shared by every long-running server binary.
6/// Flatten into a binary's clap struct with `#[command(flatten)]`.
7#[derive(clap::Args, Debug, Clone)]
8pub struct CommonServerArgs {
9    /// Seconds to wait for in-flight work to complete after SIGTERM.
10    #[arg(
11        long,
12        default_value = "25",
13        env = "MICROMEGAS_SHUTDOWN_GRACE_PERIOD_SECONDS"
14    )]
15    pub shutdown_grace_period_seconds: u64,
16}
17
18impl CommonServerArgs {
19    pub fn grace(&self) -> Duration {
20        Duration::from_secs(self.shutdown_grace_period_seconds)
21    }
22}