aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2017-05-17 07:10:41 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-05-17 15:21:13 +0200
commitfaa9dcff069e95c083dfea02d2403a0f14839fc4 (patch)
tree70be445e79ce5366967dbc309994a569073ed78a /src/main
parent69e855c7b0f0f7899a69a882cba0abd304233c97 (diff)
Add new reasons for server restart: PID_FILE_BUT_NO_SERVER, SERVER_VANISHED and SERVER_UNRESPONSIVE, since it looks like these are happening with upsetting frequency in our new grpc world.
PiperOrigin-RevId: 156271743
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cpp/blaze.cc29
-rw-r--r--src/main/cpp/global_variables.h10
2 files changed, 32 insertions, 7 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);
}
}
diff --git a/src/main/cpp/global_variables.h b/src/main/cpp/global_variables.h
index 063cdbba36..4774f29e86 100644
--- a/src/main/cpp/global_variables.h
+++ b/src/main/cpp/global_variables.h
@@ -31,7 +31,15 @@ class StartupOptions;
// The reason for a blaze server restart.
// Keep in sync with logging.proto.
-enum RestartReason { NO_RESTART = 0, NO_DAEMON, NEW_VERSION, NEW_OPTIONS };
+enum RestartReason {
+ NO_RESTART = 0,
+ NO_DAEMON,
+ NEW_VERSION,
+ NEW_OPTIONS,
+ PID_FILE_BUT_NO_SERVER,
+ SERVER_VANISHED,
+ SERVER_UNRESPONSIVE
+};
struct GlobalVariables {
GlobalVariables(OptionProcessor *option_processor);