From 905c1a71124d5acda7dd40fc7aedce4d9a5f5b2f Mon Sep 17 00:00:00 2001 From: panda-sheep <59197347+panda-sheep@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:36:22 +0800 Subject: [PATCH 1/2] Generate log directory, if it does not exist --- src/daemons/SetupLogging.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/daemons/SetupLogging.cpp b/src/daemons/SetupLogging.cpp index 4a7e73992..a686d6d1f 100644 --- a/src/daemons/SetupLogging.cpp +++ b/src/daemons/SetupLogging.cpp @@ -6,6 +6,7 @@ #include "common/base/Base.h" #include "common/base/Status.h" +#include "common/fs/FileUtils.h" DECLARE_string(log_dir); @@ -14,8 +15,17 @@ DEFINE_string(stdout_log_file, "stdout.log", "Destination filename of stdout"); DEFINE_string(stderr_log_file, "stderr.log", "Destination filename of stderr"); using nebula::Status; +using nebula::fs::FileUtils; Status setupLogging() { + // If the log directory does not exist, try to create + if (!FileUtils::exist(FLAGS_log_dir)) { + if (!FileUtils::makeDir(FLAGS_log_dir)) { + return Status::Error( + "Failed to create log directory `%s'", FLAGS_log_dir.c_str()); + } + } + if (!FLAGS_redirect_stdout) { return Status::OK(); } From 7d09c9773c4e486866bb73598622899b92da9a5f Mon Sep 17 00:00:00 2001 From: panda-sheep <59197347+panda-sheep@users.noreply.github.com> Date: Thu, 25 Mar 2021 09:20:16 +0800 Subject: [PATCH 2/2] update conf --- conf/nebula-metad.conf.default | 2 +- conf/nebula-metad.conf.production | 2 +- conf/nebula-storaged-listener.conf.production | 2 +- conf/nebula-storaged.conf.default | 2 +- conf/nebula-storaged.conf.production | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/nebula-metad.conf.default b/conf/nebula-metad.conf.default index 5945a222b..9467966f3 100644 --- a/conf/nebula-metad.conf.default +++ b/conf/nebula-metad.conf.default @@ -5,7 +5,7 @@ --pid_file=pids/nebula-metad.pid ########## logging ########## -# The directory to host logging files, which must already exists +# The directory to host logging files --log_dir=logs # Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively --minloglevel=0 diff --git a/conf/nebula-metad.conf.production b/conf/nebula-metad.conf.production index 4da2646fe..7ef1f425d 100644 --- a/conf/nebula-metad.conf.production +++ b/conf/nebula-metad.conf.production @@ -5,7 +5,7 @@ --pid_file=pids/nebula-metad.pid ########## logging ########## -# The directory to host logging files, which must already exists +# The directory to host logging files --log_dir=logs # Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively --minloglevel=0 diff --git a/conf/nebula-storaged-listener.conf.production b/conf/nebula-storaged-listener.conf.production index 9a0026c54..047f6a555 100644 --- a/conf/nebula-storaged-listener.conf.production +++ b/conf/nebula-storaged-listener.conf.production @@ -6,7 +6,7 @@ --pid_file=pids_listener/nebula-storaged.pid ########## logging ########## -# The directory to host logging files, which must already exists +# The directory to host logging files --log_dir=logs_listener # Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively --minloglevel=0 diff --git a/conf/nebula-storaged.conf.default b/conf/nebula-storaged.conf.default index 4ea64b41c..83d7e07d3 100644 --- a/conf/nebula-storaged.conf.default +++ b/conf/nebula-storaged.conf.default @@ -5,7 +5,7 @@ --pid_file=pids/nebula-storaged.pid ########## logging ########## -# The directory to host logging files, which must already exists +# The directory to host logging files --log_dir=logs # Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively --minloglevel=0 diff --git a/conf/nebula-storaged.conf.production b/conf/nebula-storaged.conf.production index 18ba06d6a..0fa745868 100644 --- a/conf/nebula-storaged.conf.production +++ b/conf/nebula-storaged.conf.production @@ -5,7 +5,7 @@ --pid_file=pids/nebula-storaged.pid ########## logging ########## -# The directory to host logging files, which must already exists +# The directory to host logging files --log_dir=logs # Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively --minloglevel=0