[−][src]Struct daemonize::Daemonize
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.
Methods
impl Daemonize<()>
[src]
impl<T> Daemonize<T>
[src]
pub fn pid_file<F: AsRef<Path>>(self, path: F) -> Self
[src]
Create pid-file at path
, lock it exclusive and write daemon pid.
pub fn chown_pid_file(self, chown: bool) -> Self
[src]
If chown
is true, daemonize will change the pid-file ownership, if user or group are provided
pub fn working_directory<F: AsRef<Path>>(self, path: F) -> Self
[src]
Change working directory to path
or /
by default.
pub fn user<U: Into<User>>(self, user: U) -> Self
[src]
Drop privileges to user
.
pub fn group<G: Into<Group>>(self, group: G) -> Self
[src]
Drop privileges to group
.
pub fn umask(self, mask: mode_t) -> Self
[src]
Change umask to mask
or 0o027
by default.
pub fn chroot<F: AsRef<Path>>(self, path: F) -> Self
[src]
Change root to path
pub fn privileged_action<N, F: FnOnce() -> N + 'static>(
self,
action: F
) -> Daemonize<N>
[src]
self,
action: F
) -> Daemonize<N>
Execute action
just before dropping privileges. Most common usecase is to open listening socket.
Result of action
execution will be returned by start
method.
pub fn exit_action<F: FnOnce() + 'static>(self, action: F) -> Daemonize<T>
[src]
Execute action
just before exiting the parent process. Most common usecase is to synchronize with
forked processes.
pub fn stdout<S: Into<Stdio>>(self, stdio: S) -> Self
[src]
Configuration for the child process's standard output stream.
pub fn stderr<S: Into<Stdio>>(self, stdio: S) -> Self
[src]
Configuration for the child process's standard error stream.
pub fn start(self) -> Result<T, DaemonizeError>
[src]
Start daemonization process.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,