Skip to content

Commit

Permalink
fix(daemon): auto-start
Browse files Browse the repository at this point in the history
  • Loading branch information
kkharji committed May 26, 2022
1 parent 3d32fbb commit 737b7db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/xbase/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub fn is_running(_: &Lua, _: ()) -> LuaResult<bool> {

/// Ensure that daemon is currently running in background
pub fn ensure(lua: &Lua, _: ()) -> LuaResult<bool> {
// FIXME(dameon): resulting in connection refused
if is_running(lua, ()).unwrap() {
Ok(false)
} else if Command::new(DAEMON_BINARY_PATH).spawn().is_ok() {
} else {
Command::new(DAEMON_BINARY_PATH).spawn().unwrap();
// Give time for the daemon to be started
std::thread::sleep(std::time::Duration::new(1, 0));
lua.info("Spawned Background Server")?;
Ok(true)
} else {
panic!("Unable to spawn background server");
}
}

0 comments on commit 737b7db

Please sign in to comment.