mirror of
https://codeberg.org/icewind/wifi-prometheus-exporter.git
synced 2026-06-03 16:44:11 +02:00
print interfaces, ctrlc
This commit is contained in:
parent
bfa79a65a3
commit
6554e20192
3 changed files with 43 additions and 1 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -57,6 +57,13 @@ async fn main() -> Result<(), MainError> {
|
|||
let port = env.get("PORT").and_then(|s| u16::from_str(s).ok()).unwrap_or(80);
|
||||
let interfaces: Vec<&str> = env.get("INTERFACES").map(|interfaces| interfaces.split(' ').collect()).unwrap_or_default();
|
||||
|
||||
if interfaces.is_empty() {
|
||||
println!("Listening on default interface");
|
||||
} else {
|
||||
println!("Listening on interfaces: {}", interfaces.join(", "));
|
||||
}
|
||||
|
||||
|
||||
let wifi_listener = Arc::new(WifiLister::new(addr, &keyfile, &pubfile, &interfaces)?);
|
||||
|
||||
// GET /hello/warp => 200 OK with body "Hello, warp!"
|
||||
|
|
@ -67,6 +74,10 @@ async fn main() -> Result<(), MainError> {
|
|||
lines.join("\n")
|
||||
});
|
||||
|
||||
ctrlc::set_handler(move || {
|
||||
std::process::exit(0);
|
||||
}).expect("Error setting Ctrl-C handler");
|
||||
|
||||
warp::serve(metrics)
|
||||
.run(([0, 0, 0, 0], port))
|
||||
.await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue