Fixed runtime error on windows (-f option not defined)

This commit is contained in:
Antoine Gersant 2017-09-21 22:35:53 -07:00
parent 85f0b77b2b
commit 70e2ea9d7b

View file

@ -52,6 +52,8 @@ use unix_daemonize::{daemonize_redirect, ChdirMode};
use core::ops::Deref; use core::ops::Deref;
use errors::*; use errors::*;
#[cfg(unix)]
use getopts::Matches;
use getopts::Options; use getopts::Options;
use iron::prelude::*; use iron::prelude::*;
use mount::Mount; use mount::Mount;
@ -88,8 +90,11 @@ fn main() {
} }
} }
#[cfg(unix)] #[cfg(unix)]
fn daemonize() -> Result<()> { fn daemonize(options : &getopts::Matches) -> Result<()> {
if options.opt_present("f") {
return Ok(());
}
let mut log_file = utils::get_data_root()?; let mut log_file = utils::get_data_root()?;
log_file.push("polaris.log"); log_file.push("polaris.log");
match daemonize_redirect(Some(&log_file), Some(&log_file), ChdirMode::NoChdir) { match daemonize_redirect(Some(&log_file), Some(&log_file), ChdirMode::NoChdir) {
@ -124,11 +129,8 @@ fn run() -> Result<()> {
return Ok(()); return Ok(());
} }
//attribute inside the if clause, because they are not yet allowed on `if` expressions
if !matches.opt_present("f") {
#[cfg(unix)] #[cfg(unix)]
daemonize()?; daemonize(&matches)?;
}
// Init DB // Init DB
println!("Starting up database"); println!("Starting up database");