diff options
Diffstat (limited to 'configd/src/apps/sentinel/service.cpp')
-rw-r--r-- | configd/src/apps/sentinel/service.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp index 5701d4b70e8..fa5af578946 100644 --- a/configd/src/apps/sentinel/service.cpp +++ b/configd/src/apps/sentinel/service.cpp @@ -91,7 +91,10 @@ int Service::terminate(bool catchable, bool dumpState) { if (isRunning()) { - runPreShutdownCommand(); + if (_state == RUNNING) { + // only run this once, before signaling the service: + runPreShutdownCommand(); + } LOG(debug, "%s: terminate(%s)", name().c_str(), catchable ? "cleanly" : "NOW"); resetRestartPenalty(); kill(_pid, SIGCONT); // if it was stopped for some reason @@ -144,8 +147,14 @@ void Service::runCommand(const std::string & command) { int ret = system(command.c_str()); - if (ret != 0) { - LOG(info, "%s: unable to run showdown command (%s): %d (%s)", name().c_str(), command.c_str(), ret, strerror(ret)); + if (ret == -1) { + LOG(error, "%s: unable to run shutdown command (%s): %s", name().c_str(), command.c_str(), strerror(errno)); + } else if (WIFSIGNALED(ret)) { + LOG(error, "%s: shutdown command (%s) terminated by signal %d", name().c_str(), command.c_str(), WTERMSIG(ret)); + } else if (ret != 0) { + LOG(warning, "%s: shutdown command (%s) failed with exit status %d", name().c_str(), command.c_str(), WEXITSTATUS(ret)); + } else { + LOG(info, "%s: shutdown command (%s) completed normally.", name().c_str(), command.c_str()); } } |