aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/cpp/blaze.cc')
-rw-r--r--src/main/cpp/blaze.cc29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index 14f976b74e..438253422a 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -531,8 +531,13 @@ static void AddLoggingArgs(vector<string> *args) {
ToString(globals->extract_data_time));
}
if (globals->restart_reason != NO_RESTART) {
- const char *reasons[] = {"no_restart", "no_daemon", "new_version",
- "new_options"};
+ const char *reasons[] = {"no_restart",
+ "no_daemon",
+ "new_version",
+ "new_options",
+ "pid_file_but_no_server",
+ "server_vanished",
+ "server_unresponsive"};
args->push_back(string("--restart_reason=") +
reasons[globals->restart_reason]);
}
@@ -700,6 +705,12 @@ static int GetServerPid(const string &server_dir) {
return result;
}
+static void SetRestartReasonIfNotSet(RestartReason restart_reason) {
+ if (globals->restart_reason == NO_RESTART) {
+ globals->restart_reason = restart_reason;
+ }
+}
+
// Starts up a new server and connects to it. Exits if it didn't work not.
static void StartServerAndConnect(const WorkspaceLayout *workspace_layout,
BlazeServer *server) {
@@ -721,10 +732,16 @@ static void StartServerAndConnect(const WorkspaceLayout *workspace_layout,
int server_pid = GetServerPid(server_dir);
if (server_pid > 0) {
if (VerifyServerProcess(server_pid, globals->options->output_base,
- globals->options->install_base) &&
- KillServerProcess(server_pid)) {
- fprintf(stderr, "Killed non-responsive server process (pid=%d)\n",
- server_pid);
+ globals->options->install_base)) {
+ if (KillServerProcess(server_pid)) {
+ fprintf(stderr, "Killed non-responsive server process (pid=%d)\n",
+ server_pid);
+ SetRestartReasonIfNotSet(SERVER_UNRESPONSIVE);
+ } else {
+ SetRestartReasonIfNotSet(SERVER_VANISHED);
+ }
+ } else {
+ SetRestartReasonIfNotSet(PID_FILE_BUT_NO_SERVER);
}
}