/** Blocks until all processes are terminated. */ public void stop() { trace("start hard stop async..."); stopAsync(State.HARD_STOPPING); trace("await termination of terminator..."); awaitTermination(terminator); cleanAfterTermination(); trace("exit..."); systemExit.exit(0); }
private void cleanAfterTermination() { trace("go to STOPPED..."); if (lifecycle.tryToMoveTo(State.STOPPED)) { trace("await termination of restartWatcher and hardStopWatcher..."); // wait for restartWatcher and hardStopWatcher to cleanly stop awaitTermination(restartWatcher, hardStopWatcher); trace("restartWatcher done"); // removing shutdown hook to avoid called stop() unnecessarily unless already in shutdownHook if (!systemExit.isInShutdownHook()) { trace("removing shutdown hook..."); Runtime.getRuntime().removeShutdownHook(shutdownHook); } // cleanly close JavaLauncher closeJavaLauncher(); } }