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]

Super

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]

Path to working directory for the daemon, this path must be a directory, must exist AND be an absolute path.

pub fn as_user(self, user: User) -> Self[src]

User to be set after going daemon

pub fn as_group(self, group: Group) -> Self[src]

Group to be set after going daemon

pub fn umask(self, umask: u16) -> Result<Self, DaemonizrError>[src]

Umask to use for daemon

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]

Set behaviour for standard output: close or redirect to the given path.

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]

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]

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().

Trait Implementations

impl Debug for Daemonizr[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.