Register custom events handlers that will be called during the lifetime of the server.
Registers a handler for resource cleanup when server is shutting down.