14个版本
使用旧的Rust 2015
| 0.5.0 | 2023年2月25日 | 
|---|---|
| 0.4.1 | 2019年3月27日 | 
| 0.3.0 | 2018年4月7日 | 
| 0.2.3 | 2016年8月29日 | 
| 0.1.0 | 2015年12月25日 | 
#17 在 Unix API 中
每月 76,698 次下载
用于 123 个 包(直接使用98个)
27KB
600 代码行
daemonize  
  
 
daemonize是一个用于编写系统守护进程的库。受Python库thesharp/daemonize的启发。
使用示例
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),
    }
}
许可证
许可协议为以下之一
- Apache许可证2.0版(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证(LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
贡献
除非您明确声明,否则您有意提交的任何贡献都应按照上述方式双许可,而无需任何附加条款或条件。
依赖关系
~43KB