nzrd: actually serve the events
This commit is contained in:
parent
f1dd375e2f
commit
f0772b10e2
14
nzrd/src/event.rs
Normal file
14
nzrd/src/event.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use std::io;
|
||||
|
||||
use tokio::net::UnixListener;
|
||||
|
||||
use crate::ctx::Context;
|
||||
|
||||
pub async fn event_server(ctx: Context) -> io::Result<()> {
|
||||
let sock = UnixListener::bind(&ctx.config.rpc.events_sock)?;
|
||||
|
||||
loop {
|
||||
let (client, addr) = sock.accept().await?;
|
||||
ctx.events.spawn(client, addr).await?;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
mod cmd;
|
||||
mod ctrl;
|
||||
mod ctx;
|
||||
mod event;
|
||||
mod model;
|
||||
mod rpc;
|
||||
|
||||
|
@ -25,8 +26,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
tracing::warn!("Couldn't parse log level from config, defaulting to {log_level}");
|
||||
}
|
||||
|
||||
if let Err(err) = rpc::serve(ctx.clone()).await {
|
||||
tracing::error!("Error from RPC: {}", err);
|
||||
// Run both the RPC and events servers
|
||||
tokio::select! {
|
||||
res = rpc::serve(ctx.clone()) => {
|
||||
if let Err(err) = res {
|
||||
tracing::error!("RPC server error: {err}");
|
||||
}
|
||||
},
|
||||
res = event::event_server(ctx.clone()) => {
|
||||
if let Err(err) = res {
|
||||
tracing::error!("Event server error: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue