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

Generate log directory, if it does not exist #873

Merged
merged 2 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
panda-sheep marked this conversation as resolved.
Show resolved Hide resolved
# 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