daemonize is a library for writing system daemons. Inspired by the Python library thesharp/daemonize.
Usage example:
extern crate daemonize;
use std::fs::File;
use daemonize::Daemonize;
fn main() {
let stdout = File::create("/tmp/daemon.out").unwrap();
let stderr = File::create("/tmp/daemon.err").unwrap();
let daemonize = Daemonize::new()
.pid_file("/tmp/test.pid") // Every method except `new` and `start`
.chown_pid_file(true) // is optional, see `Daemonize` documentation
.working_directory("/tmp") // for default behaviour.
.user("nobody")
.group("daemon") // Group name
.group(2) // or group id.
.umask(0o777) // Set umask, `0o027` by default.
.stdout(stdout) // Redirect stdout to `/tmp/daemon.out`.
.stderr(stderr) // Redirect stderr to `/tmp/daemon.err`.
.privileged_action(|| "Executed before drop privileges");
match daemonize.start() {
Ok(_) => println!("Success, daemonized"),
Err(e) => eprintln!("Error, {}", e),
}
}
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
664 followers · starred Feb 2024
392 followers · starred Dec 2023
734 followers · starred Aug 2026
82 followers · starred Oct 2024
daemonize is a library for writing system daemons. Inspired by the Python library thesharp/daemonize.
Usage example:
extern crate daemonize;
use std::fs::File;
use daemonize::Daemonize;
fn main() {
let stdout = File::create("/tmp/daemon.out").unwrap();
let stderr = File::create("/tmp/daemon.err").unwrap();
let daemonize = Daemonize::new()
.pid_file("/tmp/test.pid") // Every method except `new` and `start`
.chown_pid_file(true) // is optional, see `Daemonize` documentation
.working_directory("/tmp") // for default behaviour.
.user("nobody")
.group("daemon") // Group name
.group(2) // or group id.
.umask(0o777) // Set umask, `0o027` by default.
.stdout(stdout) // Redirect stdout to `/tmp/daemon.out`.
.stderr(stderr) // Redirect stderr to `/tmp/daemon.err`.
.privileged_action(|| "Executed before drop privileges");
match daemonize.start() {
Ok(_) => println!("Success, daemonized"),
Err(e) => eprintln!("Error, {}", e),
}
}
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
664 followers · starred Feb 2024
392 followers · starred Dec 2023
734 followers · starred Aug 2026
82 followers · starred Oct 2024