#daemon #daemonize #unix #daemonize-me

daemonize-me

Rust library to ease the task of creating daemons on unix-like systems

10 releases

0.3.1 Aug 19, 2020
0.3.0 Aug 19, 2020
0.2.1 Jun 28, 2020
0.1.3-alpha Jun 27, 2020

#125 in Unix APIs

Download history 24/week @ 2020-07-22 16/week @ 2020-08-05 24/week @ 2020-08-12 36/week @ 2020-08-19 27/week @ 2020-08-26 37/week @ 2020-09-02 2/week @ 2020-09-09 4/week @ 2020-09-16 8/week @ 2020-09-23 44/week @ 2020-09-30 43/week @ 2020-10-07 22/week @ 2020-10-14 11/week @ 2020-10-21 3/week @ 2020-10-28 31/week @ 2020-11-04

110 downloads per month

BSD-3-Clause/Apache-2.0

24KB
486 lines

daemonize-me Rust Crates.io Crates.io Crates.io

Rust library to ease the task of creating daemons, I have drawn heavy inspiration from Daemonize by knsd.

I just reached a mature enough point to call this code usable as it is now doing what it should (it still needs better testing however). This being said, I'm electing to release the library in a first version as is and keep improving it.

Basic usage

Add it to your cargo.toml this will add the whole 0.3.x series as compatible as per semver

daemonize-me = "0.3"

Example:

extern crate daemonize_me;
use daemonize_me::{Daemon, Group, User};
use std::convert::TryFrom;
use std::fs::File;

fn main() {
    let stdout = File::create("info.log").unwrap();
    let stderr = File::create("err.log").unwrap();
    let daemon = Daemon::new()
        .pid_file("example.pid", Some(false))
        .user(User::try_from("daemon").unwrap())
        .group(Group::try_from("daemon").unwrap())
        .umask(0o000)
        .work_dir(".")
        .stdout(stdout)
        .stderr(stderr)
        .start();

    match daemon {
        Ok(_) => println!("Daemonized with success"),
        Err(e) => eprintln!("Error, {}", e),
    }
}

OS support

I will try to keep support for linux, freebsd and macos

os tier
linux tier 1
freebsd, netbsd tier 2
macos, unix, *nix tier 3
Anything non unix not supported

For tier 1 any code that breaks the tests and or ci/cd is blocking for a release, tier 2 compilation errors are release blocking, tier 3 are supported on a best effort basis, and build failure as well as test failures are not blocking.

note on custom/hobby OS support, if your os implements the syscalls used in lib.rs then this library is likely to work.

Supported Versions

Version support is as follows during this highly volatile initial development period:

Version Supported
master Master is bleeding edge and thus inherently unstable
0.3.x This is the first stable version as long as it is feasible and until 1.0.0 lands it will be supported

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.

Dependencies

~2MB
~43K SLoC