}
impl Daemoniser {
+ /// Start daemonising - call before any threads created!
pub fn phase1() -> Self {
unsafe {
let null_fd = open(cstr!(b"/dev/null\0"), OFlag::O_RDWR, Mode::empty())
mod slocal;
mod sweb;
+pub use daemon::Daemoniser;
pub use sweb::{WebRequest, WebResponse, WebResponseBody};
pub use suser::User;
#[structopt(flatten)]
pub config: config::Opts,
+
+ /// Daemonise
+ #[structopt(long)]
+ daemon: bool,
}
pub const METADATA_MAX_LEN: usize = MAX_OVERHEAD;
}
}
-#[tokio::main]
-async fn main() {
+fn main() {
let opts = Opts::from_args();
+ let daemon = if opts.daemon {
+ Some(Daemoniser::phase1())
+ } else {
+ None
+ };
+
+ async_main(opts, daemon);
+}
+
+#[tokio::main]
+async fn async_main(opts: Opts, daemon: Option<Daemoniser>) {
let mut tasks: Vec<(
JoinHandle<AE>,
String,
Ok(())
});
+ if let Some(daemon) = daemon {
+ daemon.complete();
+ }
+
let (output, died_i, _) = future::select_all(
tasks.iter_mut().map(|e| &mut e.0)
).await;