#[structopt(long)]
daemon: bool,
+ /// Write our pid to this file
+ #[structopt(long)]
+ pidfile: Option<String>,
+
/// Print a config item, do not actually run
#[structopt(long)]
print_config: Option<String>,
fn main() {
let opts = Opts::from_args();
+
let daemon = if opts.daemon && opts.print_config.is_none() {
Some(Daemoniser::phase1())
} else {
}
}
+ if let Some(pidfile_path) = opts.pidfile.as_ref() {
+ (||{
+ let mut pidfile = fs::File::create(pidfile_path).context("create")?;
+ writeln!(pidfile, "{}", process::id()).context("write")?;
+ pidfile.flush().context("write (flush)")?;
+ Ok::<_,AE>(())
+ })().with_context(|| format!("pidfile {:?}", pidfile_path))?;
+ }
+
let ipif = Ipif::start(&global_config.ipif, None)?;
let ics = ics.into_iter().map(Arc::new).collect_vec();