@Singleton
public class GracefulShutdownService
extends com.google.common.util.concurrent.AbstractIdleService
Services can implement GracefulShutdownHook and register themselves with this service to make sure they
get shut down properly on server shutdown. During shutdown the registered hooks will be called in no particular
order.
Make sure to use unregister(GracefulShutdownHook) if a registered service is shutting down before the
server shutdown to avoid leaking service instances in the GracefulShutdownService.
See GracefulShutdownHook for an example.
| Constructor and Description |
|---|
GracefulShutdownService() |
| Modifier and Type | Method and Description |
|---|---|
void |
register(GracefulShutdownHook shutdownHook)
Register a shutdown hook with the service.
|
protected void |
shutDown() |
protected void |
startUp() |
void |
unregister(GracefulShutdownHook shutdownHook)
Remove a previously registered shutdown hook from the service.
|
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toStringprotected void startUp()
startUp in class com.google.common.util.concurrent.AbstractIdleServiceprotected void shutDown()
shutDown in class com.google.common.util.concurrent.AbstractIdleServicepublic void register(GracefulShutdownHook shutdownHook)
shutdownHook - a class that implements GracefulShutdownHookIllegalStateException - if the server shutdown is already in progress and the hook cannot be registeredNullPointerException - if the shutdown hook argument is nullpublic void unregister(GracefulShutdownHook shutdownHook)
This needs to be called if a registered service will be stopped before the server shuts down.
shutdownHook - a class that implements GracefulShutdownHookIllegalStateException - if the server shutdown is already in progress and the hook cannot be unregisteredNullPointerException - if the shutdown hook argument is nullCopyright © 2012–2021 Graylog, Inc.. All rights reserved.