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)]
|
#[derive(PartialEq)]
|
||||||
enum OperationMode {
|
enum OperationMode {
|
||||||
|
None,
|
||||||
Exporter,
|
Exporter,
|
||||||
Validator,
|
Validator,
|
||||||
}
|
}
|
||||||
@ -29,9 +30,9 @@ fn parse_nix_store_path(path: std::path::PathBuf) -> Result<(String, String), St
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let mut listen = String::from("[::]:9152");
|
let mut listen = String::from("[::]:9152");
|
||||||
let mut operationmode = OperationMode::Exporter;
|
let mut operationmode = OperationMode::None;
|
||||||
let mut args = std::env::args();
|
let mut args = std::env::args();
|
||||||
args.next();
|
let name = args.next().unwrap();
|
||||||
loop {
|
loop {
|
||||||
let arg = if let Some(arg) = args.next() {
|
let arg = if let Some(arg) = args.next() {
|
||||||
arg
|
arg
|
||||||
@ -69,7 +70,10 @@ async fn main() {
|
|||||||
} else if operationmode == OperationMode::Validator {
|
} else if operationmode == OperationMode::Validator {
|
||||||
println!("Running NixOS Exporter in Validator mode");
|
println!("Running NixOS Exporter in Validator mode");
|
||||||
app = app.route("/metrics", get(check));
|
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();
|
let addr = SocketAddr::from_str(&listen).unwrap();
|
||||||
println!("listening on http://{}", addr);
|
println!("listening on http://{}", addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user