[−][src]Function spirit_daemonize::extension
pub unsafe fn extension<E, C, D>(extractor: C) -> impl Extension<E> where
E: Extensible<Ok = E>,
E::Config: DeserializeOwned + Send + Sync + 'static,
E::Opts: StructOpt + Send + Sync + 'static,
C: Fn(&E::Config, &E::Opts) -> D + Send + Sync + 'static,
D: Into<Daemon>,
Creates an extension for daemonization as part of the spirit.
Goes into background (or not) as configured by configuration and options (see the crate example).
Safety
Daemonization uses fork
. Therefore, the caller must ensure this is run only before any
threads are started.
This runs in the validation phase of the config validator.
Note that many thing may start threads. Specifically, logging with a background thread and the Tokio runtime do.
If you want to have logging available before daemonization (to have some output during/after daemonization), it is possible to do a two-phase initialization ‒ once before daemonization, but without a background thread, and then after. See the [relevant chapter in the guide][spirit::guide::daemonization].