dotfiles/agent/src/bin/prymn_agent.rs
2023-06-19 14:34:09 +03:00

28 lines
656 B
Rust

use prymn_agent::new_server;
use tokio::sync::oneshot;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
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?;
Ok(())
}