Class ShutdownService
java.lang.Object
org.eclipse.jetty.server.ShutdownService
- Direct Known Subclasses:
ShutdownMonitor
Server
Shutdown Service, which will listen
to a configured Host / Port and handle commands to control the
list of Jetty Component LifeCycle
objects.
The commands you can send to this Server are always in US_ASCII
with a CRLF (\r\n
.
Supported commands:
FORCESTOP
- Will stop components by calling
LifeCycle.stop()
.
Will receiveStopped\r\n
after stop, and before exit. STOPEXIT
- Will stop components by calling
LifeCycle.stop()
,
(Each component that is aDestroyable
will also bedestroyed
) followed bySystem.exit(0);
at the end.
Will receiveStopped\r\n
after stop/destroy, and before exit. EXIT
- Will simply call
System.exit(0);
on JVM STATUS
- Will return
OK\r\n
to indicate ShutdownService is alive and ready to take commands. PID
- Will return PID of the running JVM from
ProcessHandle.current().pid()
on JVM
- Since:
- 12.1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionShutdownService
(String host, int port, String key, boolean exitVm) Create a new ShutdownService. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponent
(LifeCycle component) protected void
bound
(ServerSocket serverSocket) Event triggered with the ServerSocket is bound.protected void
configure
(ServerSocket serverSocket) Configure the ServerSocket before binding.getHost()
getKey()
int
Get theServerSocket.getLocalPort()
that this is listening on.int
getPort()
Get the configured port.boolean
hasComponent
(LifeCycle component) boolean
isExitVm()
boolean
boolean
removeComponent
(LifeCycle component) void
start()
void
stop()
toString()
-
Field Details
-
lock
-
components
-
-
Constructor Details
-
ShutdownService
public ShutdownService(@Name("host") String host, @Name("port") int port, @Name("key") String key, @Name("exitVm") boolean exitVm) Create a new ShutdownService.- Parameters:
host
- the hostport
- the portkey
- the key that must be passed to allow a shutdownexitVm
- flag to exit vm on successful shutdown
-
-
Method Details
-
addComponent
-
removeComponent
-
hasComponent
-
start
-
stop
public void stop() -
isExitVm
public boolean isExitVm() -
getHost
-
getKey
-
getPort
public int getPort()Get the configured port.If configured for port 0, then the automatically allocated port is available on
getLocalPort()
- Returns:
- the configured port
-
getLocalPort
public int getLocalPort()Get theServerSocket.getLocalPort()
that this is listening on.- Returns:
- the port that the server socket is listening on.
-
isListening
public boolean isListening() -
configure
Configure the ServerSocket before binding.- Parameters:
serverSocket
- the server socket.- Throws:
SocketException
-
bound
Event triggered with the ServerSocket is bound.- Parameters:
serverSocket
- the bound server socket.
-
toString
-