#daemon #daemonize #unix

daemonize

Library to enable your code run as a daemon process on Unix-like systems

11 releases

0.3.0 Apr 7, 2018
0.2.3 Aug 29, 2016
0.2.2 Mar 19, 2016
0.2.1 Jan 19, 2016
0.0.3 Dec 21, 2015

#5 in Unix APIs

Download history 874/week @ 2018-05-06 941/week @ 2018-05-13 840/week @ 2018-05-20 709/week @ 2018-05-27 484/week @ 2018-06-03 675/week @ 2018-06-10 503/week @ 2018-06-17 652/week @ 2018-06-24 658/week @ 2018-07-01 522/week @ 2018-07-08 594/week @ 2018-07-15 664/week @ 2018-07-22 487/week @ 2018-07-29

4,336 downloads per month

daemonize Build Status Latest Version docs

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),
    }
}

License

Licensed under either of

Contribution

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.

MIT/Apache-2.0 license

Dependencies

Reverse deps