generated from Patagia/template-nix
Compare commits
1 commit
e3fdf39cda
...
ed40a77999
Author | SHA1 | Date | |
---|---|---|---|
ed40a77999 |
1 changed files with 14 additions and 16 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue