This is a template for writing a daemon using Rust. The template includes
- Command-line argument parsing
- Config loading from hard-coded location using yaml
- A
run()
function called bymain()
to support?
operator. Errors returned fromrun()
are simply printed to stderr using theDisplay
impl, and the process exits with1
. - Logging to stderr using the log crate and controlled by the command line -v flags.
- Signal handling
To get started, clone this project and s/rust_daemon_template/foo/
.
The template can run out of the box using
cargo run -- --config ./config.yml.example
To add application logic, edit the App
type and its Application
impl in
app.rs, the command-line options in cli.rs, and the config file format in
config.rs.
- Where is the daemonization logic? There isn't any; your system's process manager should be able to handle this for you.