#![forbid(unsafe_code)]
use std::process::ExitCode;
use seiva_server::{observability, run_workers, serve, shutdown_signal, ServerConfig};
#[tokio::main(flavor = "multi_thread")]
async fn main() -> ExitCode {
observability::init();
let config = match ServerConfig::from_process_env() {
Ok(config) => config,
Err(error) => {
tracing::error!(%error, "invalid configuration");
return ExitCode::FAILURE;
}
};
tracing::info!(env = %config.env, http = %config.http_addr, "starting");
let (served, reports) = tokio::join!(
serve(config, shutdown_signal()),
run_workers(shutdown_signal())
);
for report in &reports {
tracing::info!(
passes = report.passes,
processed = report.processed,
errors = report.errors,
"worker stopped"
);
}
match served {
Ok(()) => {
tracing::info!("stopped cleanly");
ExitCode::SUCCESS
}
Err(error) => {
tracing::error!(%error, "serve failed");
ExitCode::FAILURE
}
}
}