Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion objectstore-server/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::path::PathBuf;
use std::thread;
use std::time::Duration;

use anyhow::Result;
use argh::FromArgs;
Expand All @@ -23,6 +25,7 @@ enum Command {
Run(RunCommand),
Healthcheck(HealthcheckCommand),
Version(VersionCommand),
Sleep(SleepCommand),
}

/// run the objectstore web server
Expand All @@ -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();
Expand All @@ -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.
Expand All @@ -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!()
}
}
});

Expand Down