Skip to content

Commit

Permalink
Daemonize
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Nov 27, 2023
1 parent 4fbf3e4 commit ced0845
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "GPL-3.0-only"

[dependencies]
env_logger = "0.10.0"
fork = "0.1"
lazy_static = "1.4.0"
log = "0.4.20"
notify = "6.1.1"
Expand Down
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ced0845

Please sign in to comment.