Fail on unspecified run mode
This commit is contained in:
parent
5aed8cf0ec
commit
de00a92b88
10
src/main.rs
10
src/main.rs
@ -12,6 +12,7 @@ use std::str::FromStr;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum OperationMode {
|
||||
None,
|
||||
Exporter,
|
||||
Validator,
|
||||
}
|
||||
@ -29,9 +30,9 @@ fn parse_nix_store_path(path: std::path::PathBuf) -> Result<(String, String), St
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut listen = String::from("[::]:9152");
|
||||
let mut operationmode = OperationMode::Exporter;
|
||||
let mut operationmode = OperationMode::None;
|
||||
let mut args = std::env::args();
|
||||
args.next();
|
||||
let name = args.next().unwrap();
|
||||
loop {
|
||||
let arg = if let Some(arg) = args.next() {
|
||||
arg
|
||||
@ -69,7 +70,10 @@ async fn main() {
|
||||
} else if operationmode == OperationMode::Validator {
|
||||
println!("Running NixOS Exporter in Validator mode");
|
||||
app = app.route("/metrics", get(check));
|
||||
}
|
||||
} else {
|
||||
println!("Run mode not specified, do {} --help", name);
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
||||
let addr = SocketAddr::from_str(&listen).unwrap();
|
||||
println!("listening on http://{}", addr);
|
||||
|
Loading…
Reference in New Issue
Block a user