Make the integration tests pass with gRPC client/server comms.
In particular:
- Make a SIGINT to the server interrupt every command
- Parse negative numbers on the command line correctly (std::stoi throws an exception, and I'd rather not start using C++ exceptions)
- Use "bytes" for command line arguments instead of "string" in the client/server proto . This is more principled, although we pretend all arguments are strings all over the place and it works for "blaze run" mostly by accident.
--
MOS_MIGRATED_REVID=120434432
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
index ace9459..2523136 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
@@ -838,8 +838,19 @@
* the program.
*/
private static int serverMain(Iterable<BlazeModule> modules, OutErr outErr, String[] args) {
+ InterruptSignalHandler sigintHandler = null;
try {
- RPCServer blazeServer = createBlazeRPCServer(modules, Arrays.asList(args));
+ final RPCServer blazeServer = createBlazeRPCServer(modules, Arrays.asList(args));
+
+ // Register the signal handler.
+ sigintHandler = new InterruptSignalHandler() {
+ @Override
+ protected void onSignal() {
+ LOG.severe("User interrupt");
+ blazeServer.interrupt();
+ }
+ };
+
blazeServer.serve();
return ExitCode.SUCCESS.getNumericExitCode();
} catch (OptionsParsingException e) {
@@ -851,6 +862,10 @@
} catch (AbruptExitException e) {
outErr.printErr(e.getMessage());
return e.getExitCode().getNumericExitCode();
+ } finally {
+ if (sigintHandler != null) {
+ sigintHandler.uninstall();
+ }
}
}