Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Generate log directory if not exist (#873)
Browse files Browse the repository at this point in the history
Co-authored-by: Yee <[email protected]>
  • Loading branch information
panda-sheep and yixinglu authored Mar 25, 2021
1 parent 3c66147 commit eb06442
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conf/nebula-graphd.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--enable_optimizer=true

########## 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
Expand Down
2 changes: 1 addition & 1 deletion conf/nebula-graphd.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--enable_optimizer=true

########## 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
Expand Down
9 changes: 9 additions & 0 deletions src/daemons/GraphDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using nebula::Status;
using nebula::ProcessUtils;
using nebula::graph::GraphService;
using nebula::network::NetworkUtils;
using nebula::fs::FileUtils;

static std::unique_ptr<apache::thrift::ThriftServer> gServer;

Expand Down Expand Up @@ -197,6 +198,14 @@ void signalHandler(int sig) {


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();
}
Expand Down

0 comments on commit eb06442

Please sign in to comment.