Source:
public static void launch(final AzkabanWebServer webServer) throws Exception { app = webServer; webServer.prepareAndStartServer(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { if (webServer.props.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) { logger.info("Shutting down flow trigger scheduler..."); webServer.scheduler.shutdown(); } } catch (final Exception e) { logger.error(("Exception while shutting down flow trigger service."), e); } try { if (webServer.props.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) { logger.info("Shutting down flow trigger service..."); webServer.flowTriggerService.shutdown(); } } catch (final Exception e) { logger.error(("Exception while shutting down flow trigger service."), e); } try { logger.info("Logging top memory consumers..."); logTopMemoryConsumers(); logger.info("Shutting down http server..."); webServer.close(); } catch (final Exception e) { logger.error(("Exception while shutting down web server."), e); } logger.info("kk thx bye."); } public void logTopMemoryConsumers() throws Exception { if (new File("/bin/bash").exists() && new File("/bin/ps").exists() && new File("/usr/bin/head").exists()) { logger.info("logging top memory consumer"); final java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder("/bin/bash", "-c", "/bin/ps aux --sort -rss | /usr/bin/head"); final Process p = processBuilder.start(); p.waitFor(); final InputStream is = p.getInputStream(); final java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String line = null; while ((line = reader.readLine()) != null) { logger.info(line); } is.close(); } } }); }

Target:
public static void launch(final AzkabanWebServer webServer) throws Exception { app = webServer; webServer.prepareAndStartServer(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { if (webServer.props.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) { logger.info("Shutting down flow trigger scheduler..."); webServer.scheduler.shutdown(); } } catch (final Exception e) { logger.error("Exception while shutting down flow trigger service.", e); } try { if (webServer.props.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) { logger.info("Shutting down flow trigger service..."); webServer.flowTriggerService.shutdown(); } } catch (final Exception e) { logger.error("Exception while shutting down flow trigger service.", e); } try { logger.info("Logging top memory consumers..."); logTopMemoryConsumers(); logger.info("Shutting down http server..."); webServer.close(); } catch (final Exception e) { logger.error("Exception while shutting down web server.", e); } logger.info("kk thx bye."); } public void logTopMemoryConsumers() throws Exception { if (new File("/bin/bash").exists() && new File("/bin/ps").exists() && new File("/usr/bin/head").exists()) { logger.info("logging top memory consumer"); final java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder("/bin/bash", "-c", "/bin/ps aux --sort -rss | /usr/bin/head"); final Process p = processBuilder.start(); p.waitFor(); final InputStream is = p.getInputStream(); final java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String line = null; while ((line = reader.readLine()) != null) { logger.info(line); } is.close(); } } }); }