pub struct Daemonize<T> { /* private fields */ }
Expand description
Daemonization options.
Fork the process in the background, disassociate from its process group and the control terminal.
Change umask value to 0o027
, redirect all standard streams to /dev/null
. Change working
directory to /
or provided value.
Optionally:
- maintain and lock the pid-file;
- drop user privileges;
- drop group privileges;
- change root directory;
- change the pid-file ownership to provided user (and/or) group;
- execute any provided action just before dropping privileges.
Implementations§
source§impl<T> Daemonize<T>
impl<T> Daemonize<T>
sourcepub fn pid_file<F: AsRef<Path>>(self, path: F) -> Self
pub fn pid_file<F: AsRef<Path>>(self, path: F) -> Self
Create pid-file at path
, lock it exclusive and write daemon pid.
sourcepub fn chown_pid_file(self, chown: bool) -> Self
pub fn chown_pid_file(self, chown: bool) -> Self
If chown
is true, daemonize will change the pid-file ownership, if user or group are provided
sourcepub fn working_directory<F: AsRef<Path>>(self, path: F) -> Self
pub fn working_directory<F: AsRef<Path>>(self, path: F) -> Self
Change working directory to path
or /
by default.
sourcepub fn privileged_action<N, F: FnOnce() -> N + 'static>(
self,
action: F
) -> Daemonize<N>
pub fn privileged_action<N, F: FnOnce() -> N + 'static>( self, action: F ) -> Daemonize<N>
Execute action
just before dropping privileges. Most common use case is to open
listening socket. Result of action
execution will be returned by start
method.
sourcepub fn stdout<S: Into<Stdio>>(self, stdio: S) -> Self
pub fn stdout<S: Into<Stdio>>(self, stdio: S) -> Self
Configuration for the child process’s standard output stream.
sourcepub fn stderr<S: Into<Stdio>>(self, stdio: S) -> Self
pub fn stderr<S: Into<Stdio>>(self, stdio: S) -> Self
Configuration for the child process’s standard error stream.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Daemonize<T>
impl<T> !Send for Daemonize<T>
impl<T> !Sync for Daemonize<T>
impl<T> Unpin for Daemonize<T>
impl<T> !UnwindSafe for Daemonize<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more