• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H03-May-2022-171131

src/H03-May-2022-670476

tests/H03-May-2022-136109

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D26-Mar-201918 32

.travis.ymlH A D26-Mar-20191.7 KiB4539

CHANGELOG.mdH A D27-Mar-20191.7 KiB10562

Cargo.tomlH A D01-Jan-19701 KiB3128

Cargo.toml.orig-cargoH A D27-Mar-2019485 1916

LICENSE-APACHEH A D26-Mar-201911.1 KiB203169

LICENSE-MITH A D26-Mar-20191 KiB84

README.mdH A D26-Mar-20191.9 KiB5137

README.md

1daemonize [![Build Status](https://travis-ci.org/knsd/daemonize.svg?branch=master)](https://travis-ci.org/knsd/daemonize) [![Latest Version](https://img.shields.io/crates/v/daemonize.svg)](https://crates.io/crates/daemonize/) [![docs](https://docs.rs/daemonize/badge.svg)](https://docs.rs/daemonize)
2=========
3
4
5daemonize is a library for writing system daemons. Inspired by the Python library [thesharp/daemonize](https://github.com/thesharp/daemonize).
6
7Usage example:
8
9```rust
10extern crate daemonize;
11
12use std::fs::File;
13
14use daemonize::Daemonize;
15
16fn main() {
17    let stdout = File::create("/tmp/daemon.out").unwrap();
18    let stderr = File::create("/tmp/daemon.err").unwrap();
19
20    let daemonize = Daemonize::new()
21        .pid_file("/tmp/test.pid") // Every method except `new` and `start`
22        .chown_pid_file(true)      // is optional, see `Daemonize` documentation
23        .working_directory("/tmp") // for default behaviour.
24        .user("nobody")
25        .group("daemon") // Group name
26        .group(2)        // or group id.
27        .umask(0o777)    // Set umask, `0o027` by default.
28        .stdout(stdout)  // Redirect stdout to `/tmp/daemon.out`.
29        .stderr(stderr)  // Redirect stderr to `/tmp/daemon.err`.
30        .privileged_action(|| "Executed before drop privileges");
31
32    match daemonize.start() {
33        Ok(_) => println!("Success, daemonized"),
34        Err(e) => eprintln!("Error, {}", e),
35    }
36}
37```
38
39### License
40
41Licensed under either of
42 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
43 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
44at your option.
45
46### Contribution
47
48Unless you explicitly state otherwise, any contribution intentionally submitted
49for inclusion in the work by you shall be dual licensed as above, without any
50additional terms or conditions.
51