From 7af953fd62795279121ce276a819bcc5711c5b81 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Fri, 30 Nov 2018 17:22:41 +0300 Subject: [PATCH] move daemonize before creating account provider (#10003) * move daemonize before creating account provider * daemonize: add a future-proofing comment --- parity/run.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/parity/run.rs b/parity/run.rs index fe93ef660..51a9ebd5b 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -464,6 +464,14 @@ fn execute_impl(cmd: RunCmd, logger: Arc, on_client_rq: let passwords = passwords_from_files(&cmd.acc_conf.password_files)?; + // Run in daemon mode. + // Note, that it should be called before we leave any file descriptor open, + // since `daemonize` will close them. + if let Some(pid_file) = cmd.daemon { + info!("Running as a daemon process!"); + daemonize(pid_file)?; + } + // prepare account provider let account_provider = Arc::new(prepare_account_provider(&cmd.spec, &cmd.dirs, &spec.data_dir, cmd.acc_conf, &passwords)?); @@ -544,12 +552,6 @@ fn execute_impl(cmd: RunCmd, logger: Arc, on_client_rq: // set network path. net_conf.net_config_path = Some(db_dirs.network_path().to_string_lossy().into_owned()); - // run in daemon mode - if let Some(pid_file) = cmd.daemon { - info!("Running as a daemon process!"); - daemonize(pid_file)?; - } - let restoration_db_handler = db::restoration_db_handler(&client_path, &client_config); let client_db = restoration_db_handler.open(&client_path) .map_err(|e| format!("Failed to open database {:?}", e))?;