Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server

public Class ShutdownMonitor

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStreamReader, .LineNumberReader, .OutputStream, java.net.InetAddress, .InetSocketAddress, .ServerSocket, .Socket, java.nio.charset.StandardCharsets, java.util.ArrayList, .Arrays, .LinkedHashSet, .List, .Set, java.util.function.Predicate, org.eclipse.jetty.util.IO, org.eclipse.jetty.util.component.Destroyable, .LifeCycle, org.eclipse.jetty.util.thread.AutoLock, .ShutdownThread

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
ShutdownMonitor.ShutdownMonitorRunnable

Thread for listening to STOP.PORT for command to stop Jetty.

Field Summary

Modifier and TypeField and Description
private final Set<LifeCycle>
private final AutoLock.WithCondition
private boolean
private boolean
private boolean
private final String
private String
private int

Constructor Summary

AccessConstructor and Description
private
ShutdownMonitor()

Creates a ShutdownMonitor using configuration from the System properties.

Method Summary

Modifier and TypeMethod and Description
private void
addLifeCycles(LifeCycle... lifeCycles)

public void
private boolean
private void
debug(String format, Object... args)

private void
public static void
deregister(LifeCycle lifeCycle)

public static ShutdownMonitor
public String
public int
protected boolean
public boolean
public static boolean
private ServerSocket
public static void
register(LifeCycle... lifeCycles)

private void
protected static void
public void
setDebug(boolean flag)

public void
setExitVm(boolean
true to exit the VM on shutdown
exitVm
)

Set true to exit the VM on shutdown.

public void
public void
setPort(int port)

public void
private void
stop()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_lifeCyclesback to summary
private final Set<LifeCycle> _lifeCycles
_lockback to summary
private final AutoLock.WithCondition _lock
aliveback to summary
private boolean alive
debugback to summary
private boolean debug
exitVmback to summary
private boolean exitVm
hostback to summary
private final String host
keyback to summary
private String key
portback to summary
private int port

Constructor Detail

ShutdownMonitorback to summary
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

addLifeCyclesback to summary
private void addLifeCycles(LifeCycle... lifeCycles)
awaitback to summary
public void await() throws InterruptedException
containsLifeCycleback to summary
private boolean containsLifeCycle(LifeCycle lifeCycle)
debugback to summary
private void debug(String format, Object... args)
debugback to summary
private void debug(Throwable t)
deregisterback to summary
public static void deregister(LifeCycle lifeCycle)
getInstanceback to summary
public static ShutdownMonitor getInstance()
getKeyback to summary
public String getKey()
getPortback to summary
public int getPort()
isAliveback to summary
protected boolean isAlive()
isExitVmback to summary
public boolean isExitVm()
isRegisteredback to summary
public static boolean isRegistered(LifeCycle lifeCycle)
listenback to summary
private ServerSocket listen()
registerback to summary
public static void register(LifeCycle... lifeCycles)
removeLifeCycleback to summary
private void removeLifeCycle(LifeCycle lifeCycle)
resetback to summary
protected static void reset()
setDebugback to summary
public void setDebug(boolean flag)
setExitVmback to summary
public void setExitVm(boolean exitVm)

Set true to exit the VM on shutdown.

Parameters
exitVm:boolean

true to exit the VM on shutdown

setKeyback to summary
public void setKey(String key)
setPortback to summary
public void setPort(int port)
startback to summary
public void start() throws Exception
stopback to summary
private void stop()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.server back to summary

private Class ShutdownMonitor.Holder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static ShutdownMonitor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
pack-priv static ShutdownMonitor instance

Constructor Detail

Holderback to summary
private Holder()
org.eclipse.jetty.server back to summary

private Class ShutdownMonitor.ShutdownMonitorRunnable

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.server.ShutdownMonitor.ShutdownMonitorRunnable
All Implemented Interfaces
java.lang.Runnable

Thread for listening to STOP.PORT for command to stop Jetty. If ShutdownMonitor.exitVm is true, then System.exit will also be called after the stop.

Field Summary

Modifier and TypeField and Description
private final ServerSocket

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
private void
stopLifeCycles(Predicate<LifeCycle> predicate, boolean destroy)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serverSocketback to summary
private final ServerSocket serverSocket

Constructor Detail

ShutdownMonitorRunnableback to summary
private ShutdownMonitorRunnable(ServerSocket serverSocket)

Method Detail

informClientback to summary
private void informClient(OutputStream out, String message) throws IOException
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
stopLifeCyclesback to summary
private void stopLifeCycles(Predicate<LifeCycle> predicate, boolean destroy)