nzrd: actually serve the events
This commit is contained in:
parent
f1dd375e2f
commit
f0772b10e2
2 changed files with 27 additions and 2 deletions
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 cmd;
|
||||||
mod ctrl;
|
mod ctrl;
|
||||||
mod ctx;
|
mod ctx;
|
||||||
|
mod event;
|
||||||
mod model;
|
mod model;
|
||||||
mod rpc;
|
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}");
|
tracing::warn!("Couldn't parse log level from config, defaulting to {log_level}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = rpc::serve(ctx.clone()).await {
|
// Run both the RPC and events servers
|
||||||
tracing::error!("Error from RPC: {}", err);
|
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(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue