Skip to content

Commit

Permalink
revert RouteGuideServer
Browse files Browse the repository at this point in the history
  • Loading branch information
laglangyue committed Apr 14, 2024
1 parent c5abab9 commit dfdff9d
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ public RouteGuideServer(ServerBuilder<?> serverBuilder, int port, Collection<Fea
public void start() throws IOException {
server.start();
logger.info("Server started, listening on " + port);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
RouteGuideServer.this.stop();
} catch (InterruptedException e) {
e.printStackTrace(System.err);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
RouteGuideServer.this.stop();
} catch (InterruptedException e) {
e.printStackTrace(System.err);
}
System.err.println("*** server shut down");
}
System.err.println("*** server shut down");
}));
});
}

/** Stop serving requests and shutdown resources. */
Expand Down

0 comments on commit dfdff9d

Please sign in to comment.