Struct daemonizr::Daemonizr [−][src]
pub struct Daemonizr { /* fields omitted */ }
Daemonizr holds context needed for spawning the daemon process.
It includes:
- working directory of the daemon;
- UID and GID to be set to after going daemon;
- umask which daemon uses after dropping the privileges;
- the PID file to use;
- setup for stdout/stderr files
Implementations
impl Daemonizr
[src]
impl Daemonizr
[src]Super
pub fn new() -> Self
[src]
pub fn new() -> Self
[src]Creates a new default Daemonizr context with following attributes:
- current directory is used as working directory;
- current user and his default group used for daemon;
- the umask() is set to 0 (means creation mode = 777);
- PID file “daemonizr.pid” in current directory is used as PID file;
- the stdout and stderr are both closed.
pub fn work_dir(self, work_dir: PathBuf) -> Result<Self, DaemonizrError>
[src]
pub fn work_dir(self, work_dir: PathBuf) -> Result<Self, DaemonizrError>
[src]Path to working directory for the daemon, this path must be a directory, must exist AND be an absolute path.
pub fn umask(self, umask: u16) -> Result<Self, DaemonizrError>
[src]
pub fn umask(self, umask: u16) -> Result<Self, DaemonizrError>
[src]Umask to use for daemon
pub fn pidfile(self, pidfile: PathBuf) -> Self
[src]
pub fn pidfile(self, pidfile: PathBuf) -> Self
[src]Path for the pidfile. If path is a relative path, it is assumed to be relative to the working directory.
pub fn stdout(self, s: Stdout) -> Self
[src]
pub fn stdout(self, s: Stdout) -> Self
[src]Set behaviour for standard output: close or redirect to the given path.
pub fn stderr(self, s: Stderr) -> Self
[src]
pub fn stderr(self, s: Stderr) -> Self
[src]Set behaviour for standard error: close or redirect to the given path.
pub fn spawn(self) -> Result<(), DaemonizrError>
[src]
pub fn spawn(self) -> Result<(), DaemonizrError>
[src]Perform the actual creation of a daemon process. In case of success, this function never returns - the parent process will exit with exit code 0 (success), the child (daemon) process will
pub fn search(self) -> Result<u32, DaemonizrError>
[src]
pub fn search(self) -> Result<u32, DaemonizrError>
[src]Search for PID of an already spawned daemon. If one is present, its PID is returned, otherwise an error is returned.
Hint: for search, you’ll need to set at least absolute path with Self::pidfile()
,
or, set absolute path using Self::work_dir()
in conjuction with setting a relative
path using Self::pidfile()
.