Class ShutdownMonitor

java.lang.Object
org.eclipse.jetty.server.ShutdownMonitor

public class ShutdownMonitor extends Object
Shutdown/Stop Monitor thread.

This thread listens on the host/port specified by the STOP.HOST/STOP.PORT system parameter (defaults to 127.0.0.1/-1 for not listening) for request authenticated with the key given by the STOP.KEY system parameter for admin requests.

If the stop port is set to zero, then a random port is assigned and the port number is printed to stdout.

Commands "stop" and "status" are currently supported.

  • Field Details

    • _lifeCycles

      private final Set<LifeCycle> _lifeCycles
    • debug

      private boolean debug
    • host

      private final String host
    • port

      private int port
    • key

      private String key
    • exitVm

      private boolean exitVm
    • alive

      private boolean alive
  • Constructor Details

    • ShutdownMonitor

      private ShutdownMonitor()
      Creates a ShutdownMonitor using configuration from the System properties.

      STOP.PORT = the port to listen on (empty, null, or values less than 0 disable the stop ability)
      STOP.KEY = the magic key/passphrase to allow the stop

      Note: server socket will only listen on localhost, and a successful stop will issue a System.exit() call.

  • Method Details

    • getInstance

      public static ShutdownMonitor getInstance()
    • reset

      protected static void reset()
    • register

      public static void register(LifeCycle... lifeCycles)
    • deregister

      public static void deregister(LifeCycle lifeCycle)
    • isRegistered

      public static boolean isRegistered(LifeCycle lifeCycle)
    • addLifeCycles

      private void addLifeCycles(LifeCycle... lifeCycles)
    • removeLifeCycle

      private void removeLifeCycle(LifeCycle lifeCycle)
    • containsLifeCycle

      private boolean containsLifeCycle(LifeCycle lifeCycle)
    • debug

      private void debug(String format, Object... args)
    • debug

      private void debug(Throwable t)
    • getKey

      public String getKey()
    • getPort

      public int getPort()
    • isExitVm

      public boolean isExitVm()
    • setDebug

      public void setDebug(boolean flag)
    • setExitVm

      public void setExitVm(boolean exitVm)
      Parameters:
      exitVm - true to exit the VM on shutdown
    • setKey

      public void setKey(String key)
    • setPort

      public void setPort(int port)
    • start

      protected void start() throws Exception
      Throws:
      Exception
    • stop

      private void stop()
    • await

      void await() throws InterruptedException
      Throws:
      InterruptedException
    • isAlive

      protected boolean isAlive()
    • listen

      private ServerSocket listen()
    • toString

      public String toString()
      Overrides:
      toString in class Object