Package org.eclipse.jetty.server
Class ShutdownMonitor
- java.lang.Object
-
- org.eclipse.jetty.server.ShutdownMonitor
-
public class ShutdownMonitor extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ShutdownMonitor.Holder
private class
ShutdownMonitor.ShutdownMonitorRunnable
Thread for listening to STOP.PORT for command to stop Jetty.
-
Constructor Summary
Constructors Modifier Constructor Description private
ShutdownMonitor()
Creates a ShutdownMonitor using configuration from the System properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addLifeCycles(LifeCycle... lifeCycles)
(package private) void
await()
private boolean
containsLifeCycle(LifeCycle lifeCycle)
private void
debug(java.lang.String format, java.lang.Object... args)
private void
debug(java.lang.Throwable t)
static void
deregister(LifeCycle lifeCycle)
static ShutdownMonitor
getInstance()
java.lang.String
getKey()
int
getPort()
protected boolean
isAlive()
boolean
isExitVm()
static boolean
isRegistered(LifeCycle lifeCycle)
private java.net.ServerSocket
listen()
static void
register(LifeCycle... lifeCycles)
private void
removeLifeCycle(LifeCycle lifeCycle)
protected static void
reset()
void
setDebug(boolean flag)
void
setExitVm(boolean exitVm)
void
setKey(java.lang.String key)
void
setPort(int port)
protected void
start()
private void
stop()
java.lang.String
toString()
-
-
-
Field Detail
-
_lifeCycles
private final java.util.Set<LifeCycle> _lifeCycles
-
debug
private boolean debug
-
host
private final java.lang.String host
-
port
private int port
-
key
private java.lang.String key
-
exitVm
private boolean exitVm
-
alive
private boolean alive
-
-
Constructor Detail
-
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 Detail
-
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(java.lang.String format, java.lang.Object... args)
-
debug
private void debug(java.lang.Throwable t)
-
getKey
public java.lang.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(java.lang.String key)
-
setPort
public void setPort(int port)
-
start
protected void start() throws java.lang.Exception
- Throws:
java.lang.Exception
-
stop
private void stop()
-
await
void await() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
isAlive
protected boolean isAlive()
-
listen
private java.net.ServerSocket listen()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-