dotfiles/agent/src/bin/prymn_agent.rs

29 lines
656 B
Rust
Raw Normal View History

2023-06-13 13:02:49 +00:00
use prymn_agent::new_server;
2023-06-19 11:34:09 +00:00
use tokio::sync::oneshot;
2023-06-13 13:02:49 +00:00
#[tokio::main]
async fn main() -> anyhow::Result<()> {
2023-06-19 11:34:09 +00:00
tracing_subscriber::fmt().init();
let (shutdown_tx, shutdown_rx) = oneshot::channel();
tokio::spawn(async {
tokio::signal::ctrl_c()
.await
.expect("could not listen to ctrl_c signal");
shutdown_tx.send(()).expect("bug: channel closed");
});
let addr = "0.0.0.0:5012".parse()?;
tracing::info!("Serving new agent at address: {}", addr);
new_server()
.serve_with_shutdown(addr, async {
let _ = shutdown_rx.await;
})
.await?;
2023-06-13 13:02:49 +00:00
Ok(())
}