Daemonize

This commit is contained in:
Jeremy Soller 2023-11-27 14:46:10 -07:00
parent 4fbf3e4663
commit ced0845c24
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
3 changed files with 20 additions and 0 deletions

View file

@ -60,6 +60,15 @@ lazy_static::lazy_static! {
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
match fork::daemon(false, false) {
Ok(fork::Fork::Child) => (),
Ok(fork::Fork::Parent(_child_pid)) => process::exit(0),
Err(err) => {
eprintln!("failed to daemonize: {:?}", err);
process::exit(1);
}
}
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
localize::localize();