Compare commits

..

1 commit

View file

@ -1,10 +1,12 @@
use anyhow::Result;
use std::process::exit;
use crate::io_patagia_hostd::{Call_Apply, Call_Describe, Label, Machine, VarlinkInterface};
use crate::io_patagia_hostd::{
Call_Apply, Call_Describe, Label, Machine, PatagiaAgentConfig, VarlinkInterface,
};
mod io_patagia_hostd;
const LISTEN_ADDRESS: &str = "unix:/tmp/patagia/io.patagia.hostd";
const LISTEN_ADDRESS: &str = "unix:/tmp/io.patagia.hostd";
struct PatagiaHostd;
@ -35,7 +37,7 @@ impl VarlinkInterface for PatagiaHostd {
}
}
fn main() -> Result<()> {
fn main() {
let hostd = PatagiaHostd;
let hostd_iface = io_patagia_hostd::new(Box::new(hostd));
@ -47,15 +49,8 @@ fn main() -> Result<()> {
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);
varlink::listen(
let ret: Result<(), varlink::Error> = varlink::listen(
svc,
LISTEN_ADDRESS,
&varlink::ListenConfig {
@ -63,7 +58,14 @@ fn main() -> Result<()> {
idle_timeout: 0,
..Default::default()
},
)?;
);
Ok(())
// Exit with error code
exit(match ret {
Ok(_) => 0,
Err(e) => {
println!("Error: {}", e);
1
}
});
}