diff --git a/objectstore-server/src/cli.rs b/objectstore-server/src/cli.rs index 0b26c63..2bb9de2 100644 --- a/objectstore-server/src/cli.rs +++ b/objectstore-server/src/cli.rs @@ -1,4 +1,6 @@ use std::path::PathBuf; +use std::thread; +use std::time::Duration; use anyhow::Result; use argh::FromArgs; @@ -23,6 +25,7 @@ enum Command { Run(RunCommand), Healthcheck(HealthcheckCommand), Version(VersionCommand), + Sleep(SleepCommand), } /// run the objectstore web server @@ -43,6 +46,14 @@ struct HealthcheckCommand {} #[argh(subcommand, name = "version")] struct VersionCommand {} +/// sleep for the specified number of seconds +#[derive(Debug, FromArgs)] +#[argh(subcommand, name = "sleep")] +struct SleepCommand { + #[argh(positional)] + seconds: u64, +} + /// Bootstrap the runtime and execute the CLI command. pub fn execute() -> Result<()> { let args: Args = argh::from_env(); @@ -53,6 +64,11 @@ pub fn execute() -> Result<()> { return Ok(()); } + if let Command::Sleep(SleepCommand { seconds }) = args.command { + thread::sleep(Duration::from_secs(seconds)); + return Ok(()); + } + let config = Config::load(args.config.as_deref())?; // Ensure a rustls crypto provider is installed, required on distroless. @@ -79,7 +95,9 @@ pub fn execute() -> Result<()> { match args.command { Command::Run(RunCommand {}) => web::server(config).await, Command::Healthcheck(HealthcheckCommand {}) => healthcheck::healthcheck(config).await, - Command::Version(VersionCommand {}) => unreachable!(), + Command::Version(VersionCommand {}) | Command::Sleep(SleepCommand { .. }) => { + unreachable!() + } } });