Skip to content

Commit

Permalink
minieap: Delay daemonizing until startup finishes
Browse files Browse the repository at this point in the history
* It's annoying when I found errors such as
  "Operation not permitted" in log file...
  Just print them before daemonizing so that
  we can see more errors on stdout, allowing
  quicker responses.
  • Loading branch information
updateing committed Dec 14, 2016
1 parent 347c7c6 commit 5611b61
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions minieap.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,6 @@ static int init_cfg(int argc, char* argv[]) {
/* Parsed in parse_config_file(). This is no longer needed */
conf_parser_free();

if (cfg->run_in_background) {
PR_INFO("正在转入后台运行……");
if (IS_FAIL(go_background())) {
PR_WARN("无法应用后台运行设置");
}
}

/* Apply log destination */
close_log();
start_log();

return SUCCESS;
}

Expand Down Expand Up @@ -155,6 +144,21 @@ static int init_if() {
return SUCCESS;
}

static void apply_log_daemon_params() {
PROG_CONFIG* cfg = get_program_config();

if (cfg->run_in_background) {
PR_INFO("正在转入后台运行……");
if (IS_FAIL(go_background())) {
PR_WARN("无法应用后台运行设置");
}
}

/* Apply log destination */
close_log();
start_log();
}

static void exit_handler() {
free_config();
free_if_impl();
Expand Down Expand Up @@ -195,6 +199,8 @@ int main(int argc, char* argv[]) {
return FAILURE;
}

apply_log_daemon_params();

switch_to_state(EAP_STATE_PREPARING, NULL);

return 0;
Expand Down

0 comments on commit 5611b61

Please sign in to comment.