Compare commits
2 Commits
31a54b7389
...
c3c5ff4ebe
Author | SHA1 | Date | |
---|---|---|---|
c3c5ff4ebe | |||
9d0f35db70 |
11
README.md
Normal file
11
README.md
Normal 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"
|
||||
```
|
26
src/main.rs
26
src/main.rs
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user