Add shutdown hook to PantheonCommand (#249)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Lucas Saldanha 6 years ago committed by GitHub
parent ef9162bebd
commit a44d696117
  1. 14
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java

@ -493,9 +493,23 @@ public class PantheonCommand implements Runnable {
webSocketConfiguration,
dataDir);
addShutdownHook(runner);
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.
// 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.

Loading…
Cancel
Save