private void shutdownInput(Socket socket) { if (socket == null) return; try { socket.shutdownInput(); } catch (IOException ignore) { debug(ignore); } }
private void close(Socket socket) { if (socket == null) { return; } try { socket.close(); } catch (IOException ignore) { debug(ignore); } }
private void close(ServerSocket server) { if (server == null) { return; } try { server.close(); } catch (IOException ignore) { debug(ignore); } }
protected void start() throws Exception { synchronized (this) { if (alive) { debug("Already started"); return; // cannot start it again } ServerSocket serverSocket = listen(); if (serverSocket != null) { alive = true; Thread thread = new Thread(new ShutdownMonitorRunnable(serverSocket)); thread.setDaemon(true); thread.setName("ShutdownMonitor"); thread.start(); } } }
debug("command=%s",cmd); if ("stop".equals(cmd)) debug("Issuing graceful shutdown.."); ShutdownThread.getInstance().run(); debug("Informing client that we are stopped."); out.write("Stopped\r\n".getBytes(StringUtil.__UTF8)); out.flush(); debug("Shutting down monitor"); close(socket); close(serverSocket); debug("Killing JVM"); System.exit(0); debug(e); System.err.println(e.toString());
debug("command=%s",cmd); if ("stop".equals(cmd)) debug("Issuing graceful shutdown.."); ShutdownThread.getInstance().run(); debug("Informing client that we are stopped."); out.write("Stopped\r\n".getBytes(StringUtil.__UTF8)); out.flush(); debug("Shutting down monitor"); close(socket); socket = null; debug("Killing JVM"); System.exit(0); debug(e); System.err.println(e.toString());
debug("command=%s",cmd); if ("stop".equals(cmd)) debug("Issuing graceful shutdown.."); ShutdownThread.getInstance().run(); debug("Informing client that we are stopped."); out.write("Stopped\r\n".getBytes(StringUtil.__UTF8)); out.flush(); debug("Shutting down monitor"); close(socket); close(serverSocket); debug("Killing JVM"); System.exit(0); debug(e); System.err.println(e.toString());
protected void start() throws Exception { synchronized (this) { if (alive) { debug("Already started"); return; // cannot start it again } ServerSocket serverSocket = listen(); if (serverSocket != null) { alive = true; Thread thread = new Thread(new ShutdownMonitorRunnable(serverSocket)); thread.setDaemon(true); thread.setName("ShutdownMonitor"); thread.start(); } } }