diff --git a/hostd/src/main.rs b/hostd/src/main.rs index e319394..3e9dccb 100644 --- a/hostd/src/main.rs +++ b/hostd/src/main.rs @@ -1,12 +1,10 @@ -use std::process::exit; +use anyhow::Result; -use crate::io_patagia_hostd::{ - Call_Apply, Call_Describe, Label, Machine, PatagiaAgentConfig, VarlinkInterface, -}; +use crate::io_patagia_hostd::{Call_Apply, Call_Describe, Label, Machine, VarlinkInterface}; mod io_patagia_hostd; -const LISTEN_ADDRESS: &str = "unix:/tmp/io.patagia.hostd"; +const LISTEN_ADDRESS: &str = "unix:/tmp/patagia/io.patagia.hostd"; struct PatagiaHostd; @@ -37,7 +35,7 @@ impl VarlinkInterface for PatagiaHostd { } } -fn main() { +fn main() -> Result<()> { let hostd = PatagiaHostd; let hostd_iface = io_patagia_hostd::new(Box::new(hostd)); @@ -49,8 +47,15 @@ fn main() { vec![Box::new(hostd_iface)], ); + let addr_path = std::path::Path::new(LISTEN_ADDRESS.strip_prefix("unix:").unwrap()) + .parent() + .unwrap(); + + std::fs::create_dir_all(addr_path)?; + println!("Varlink Listening on {}", LISTEN_ADDRESS); - let ret: Result<(), varlink::Error> = varlink::listen( + + varlink::listen( svc, LISTEN_ADDRESS, &varlink::ListenConfig { @@ -58,14 +63,7 @@ fn main() { idle_timeout: 0, ..Default::default() }, - ); + )?; - // Exit with error code - exit(match ret { - Ok(_) => 0, - Err(e) => { - println!("Error: {}", e); - 1 - } - }); + Ok(()) }