Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/knsd/daemonize
Library for writing system daemons
https://github.com/knsd/daemonize
daemon daemonize linux osx rust system
Last synced: 7 days ago
JSON representation
Library for writing system daemons
- Host: GitHub
- URL: https://github.com/knsd/daemonize
- Owner: knsd
- License: apache-2.0
- Created: 2015-06-08T08:14:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-14T20:32:02.000Z (11 months ago)
- Last Synced: 2024-12-20T01:12:55.977Z (14 days ago)
- Topics: daemon, daemonize, linux, osx, rust, system
- Language: Rust
- Homepage:
- Size: 2.41 MB
- Stars: 529
- Watchers: 8
- Forks: 60
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
daemonize [![Build Status](https://github.com/knsd/daemonize/actions/workflows/rust.yml/badge.svg)](https://github.com/knsd/daemonize/actions/workflows/rust.yml/) [![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)
=========daemonize is a library for writing system daemons. Inspired by the Python library [thesharp/daemonize](https://github.com/thesharp/daemonize).
Usage example:
```rust
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
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.### 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.