Skip to content

Commit

Permalink
fix multi daemon can't start on same node (vesoft-inc#2289)
Browse files Browse the repository at this point in the history
* fix multi daemon can't start on same node

* address comments
  • Loading branch information
critical27 authored Aug 11, 2020
1 parent 339d0c5 commit 1d2a346
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/daemons/GraphDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ static void printHelp(const char *prog);
DECLARE_string(flagfile);

int main(int argc, char *argv[]) {
// Detect if the server has already been started
// Check pid before glog init, in case of user may start daemon twice
// the 2nd will make the 1st failed to output log anymore
auto pidPath = FLAGS_pid_file;
auto status = ProcessUtils::isPidAvailable(pidPath);
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}

google::SetVersionString(nebula::versionString());
if (argc == 1) {
printHelp(argv[0]);
Expand All @@ -55,6 +45,17 @@ int main(int argc, char *argv[]) {
}
}

// Detect if the server has already been started
// Check pid before glog init, in case of user may start daemon twice
// the 2nd will make the 1st failed to output log anymore
gflags::ParseCommandLineFlags(&argc, &argv, true);
auto pidPath = FLAGS_pid_file;
auto status = ProcessUtils::isPidAvailable(pidPath);
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}

folly::init(&argc, &argv, true);

if (FLAGS_flagfile.empty()) {
Expand Down
1 change: 1 addition & 0 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ int main(int argc, char *argv[]) {
// Detect if the server has already been started
// Check pid before glog init, in case of user may start daemon twice
// the 2nd will make the 1st failed to output log anymore
gflags::ParseCommandLineFlags(&argc, &argv, true);
auto pidPath = FLAGS_pid_file;
auto status = ProcessUtils::isPidAvailable(pidPath);
if (!status.ok()) {
Expand Down
1 change: 1 addition & 0 deletions src/daemons/StorageDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int main(int argc, char *argv[]) {
// Detect if the server has already been started
// Check pid before glog init, in case of user may start daemon twice
// the 2nd will make the 1st failed to output log anymore
gflags::ParseCommandLineFlags(&argc, &argv, true);
auto pidPath = FLAGS_pid_file;
auto status = ProcessUtils::isPidAvailable(pidPath);
if (!status.ok()) {
Expand Down

0 comments on commit 1d2a346

Please sign in to comment.