Compare commits

..

2 Commits

Author SHA1 Message Date
c3c5ff4ebe Add option to add port to listen on 2024-07-14 20:21:07 +02:00
9d0f35db70 Add README 2024-07-14 20:13:20 +02:00
2 changed files with 36 additions and 1 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# berlinerbaeder-exporter
Prometheus exporter for occupancy of open air pools operated by the city of Berlin.
There is also a Map: <https://www.berlinerbaeder.de/baeder/sommerbaeder-auslastung/>
## Run
```
berlinerbaeder-exporter --listen "[::]:1234"
```

View File

@ -29,11 +29,35 @@ struct TrafficDataItem {
#[tokio::main]
async fn main() {
let mut args = std::env::args();
let _name = args.next().unwrap();
let mut listen = String::from("[::]:3000");
loop {
let arg = if let Some(arg) = args.next() {
arg
} else {
break;
};
match arg.as_str() {
"--listen" => {
listen = args.next().unwrap();
}
unknown => {
println!("unknown option: {}", unknown);
std::process::exit(1)
}
}
}
let app = Router::new()
.route("/", get(route_index))
.route("/metrics", get(route_metrics));
let listener = tokio::net::TcpListener::bind("[::]:3000").await.unwrap();
let listener = tokio::net::TcpListener::bind(listen).await.unwrap();
println!("Server listening on: http://{}", listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap();