public class ShutdownMonitor
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
private static class |
ShutdownMonitor.Holder |
private class |
ShutdownMonitor.ShutdownMonitorRunnable
Thread for listening to STOP.PORT for command to stop Jetty.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Set<LifeCycle> |
_lifeCycles |
private boolean |
alive |
private boolean |
debug |
private boolean |
exitVm |
private java.lang.String |
host |
private java.lang.String |
key |
private int |
port |
Modifier | Constructor and Description |
---|---|
private |
ShutdownMonitor()
Creates a ShutdownMonitor using configuration from the System properties.
|
Modifier and Type | Method and 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() |
private final java.util.Set<LifeCycle> _lifeCycles
private boolean debug
private final java.lang.String host
private int port
private java.lang.String key
private boolean exitVm
private boolean alive
private ShutdownMonitor()
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.
public static ShutdownMonitor getInstance()
protected static void reset()
public static void register(LifeCycle... lifeCycles)
public static void deregister(LifeCycle lifeCycle)
public static boolean isRegistered(LifeCycle lifeCycle)
private void addLifeCycles(LifeCycle... lifeCycles)
private void removeLifeCycle(LifeCycle lifeCycle)
private boolean containsLifeCycle(LifeCycle lifeCycle)
private void debug(java.lang.String format, java.lang.Object... args)
private void debug(java.lang.Throwable t)
public java.lang.String getKey()
public int getPort()
public boolean isExitVm()
public void setDebug(boolean flag)
public void setExitVm(boolean exitVm)
exitVm
- true to exit the VM on shutdownpublic void setKey(java.lang.String key)
public void setPort(int port)
protected void start() throws java.lang.Exception
java.lang.Exception
private void stop()
void await() throws java.lang.InterruptedException
java.lang.InterruptedException
protected boolean isAlive()
private java.net.ServerSocket listen()
public java.lang.String toString()
toString
in class java.lang.Object