Add shutdown hook to PantheonCommand (#249)

Lucas Saldanha 6 years ago committed by GitHub
parent 5053711e88
commit b020029802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java

@ -493,9 +493,23 @@ public class PantheonCommand implements Runnable {
webSocketConfiguration, webSocketConfiguration,
dataDir); dataDir);
addShutdownHook(runner);
runner.execute(); runner.execute();
} }
private void addShutdownHook(final Runner runner) {
Runtime.getRuntime()
.addShutdownHook(
new Thread(
() -> {
try {
runner.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}));
}
// Used to discover the default IP of the client. // Used to discover the default IP of the client.
// Loopback IP is used by default as this is how smokeTests require it to be // Loopback IP is used by default as this is how smokeTests require it to be
// and it's probably a good security behaviour to default only on the localhost. // and it's probably a good security behaviour to default only on the localhost.

Loading…
Cancel
Save