mirror of
https://github.com/emqx/neuron.git
synced 2026-10-22 09:23:52 +08:00
fix: daemonize before zlog initialization
This commit is contained in:
+1
-7
@@ -101,7 +101,6 @@ static inline size_t parse_restart_policy(const char *s, size_t *out)
|
||||
void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
|
||||
{
|
||||
char * opts = "c:dh";
|
||||
bool dev_log = false;
|
||||
struct option long_options[] = {
|
||||
{ "help", no_argument, NULL, 1 },
|
||||
{ "daemon", no_argument, NULL, 'd' },
|
||||
@@ -129,8 +128,7 @@ void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
|
||||
usage();
|
||||
goto quit;
|
||||
case 'l':
|
||||
zlog_init("./config/dev.conf");
|
||||
dev_log = true;
|
||||
args->dev_log = true;
|
||||
break;
|
||||
case 'r':
|
||||
if (0 != parse_restart_policy(optarg, &args->restart)) {
|
||||
@@ -155,10 +153,6 @@ void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (!dev_log) {
|
||||
zlog_init("./config/zlog.conf");
|
||||
}
|
||||
|
||||
if (!args->daemonized && args->restart != NEU_RESTART_NEVER) {
|
||||
fprintf(stderr,
|
||||
"%s: option '--restart' has no effects without '--daemon'\n",
|
||||
|
||||
@@ -37,6 +37,7 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
bool daemonized; // flag indicating whether to run as daemon process
|
||||
bool dev_log; // logging for development
|
||||
size_t restart; // restart policy
|
||||
bool disable_auth;
|
||||
} neu_cli_args_t;
|
||||
|
||||
@@ -85,6 +85,12 @@ int main(int argc, char *argv[])
|
||||
// become a daemon, this should be before calling `init`
|
||||
daemonize();
|
||||
}
|
||||
|
||||
if (args.dev_log) {
|
||||
zlog_init("./config/dev.conf");
|
||||
} else {
|
||||
zlog_init("./config/zlog.conf");
|
||||
}
|
||||
neuron = zlog_get_category("neuron");
|
||||
|
||||
if (neuron_already_running()) {
|
||||
|
||||
Reference in New Issue
Block a user