Protocol
LifecycleHandler
Provides a way to hook into lifecycle events of a Vapor application. You can register your handlers with the
Application to be notified when the application is about to start up, has started up and is about to shutdownprotocol LifecycleHandler : Sendable
Overview
For example
struct LifecycleLogger: LifecycleHander {
func willBootAsync(_ application: Application) async throws {
application.logger.info("Application about to boot up")
}
func didBootAsync(_ application: Application) async throws {
application.logger.info("Application has booted up")
}
func shutdownAsync(_ application: Application) async {
application.logger.info("Will shutdown")
}
}
You can then register your handler with the application:
application.lifecycle.use(LifecycleLogger())
Topics
Instance Methods
didBoot(_:)Called when the application has booted updidBootAsync(_:)Called when the application is about to boot up. This is the asynchronous version ofdidBoot(_:). When adopting the async APIs you should ensure you provide a compatitble implementation fordidBoot(_:)as well if you want to support older users still running in a non-async context Note your application must be running in an asynchronous context and initialised withmake(_:_:)for this handler to be calledshutdown(_:)Called when the application is about to shutdownshutdownAsync(_:)Called when the application is about to boot up. This is the asynchronous version ofshutdown(_:). When adopting the async APIs you should ensure you provide a compatitble implementation forshutdown(_:)as well if you want to support older users still running in a non-async context Note your application must be running in an asynchronous context and initialised withmake(_:_:)for this handler to be calledwillBoot(_:)Called when the application is about to boot upwillBootAsync(_:)Called when the application is about to boot up. This is the asynchronous version ofwillBoot(_:). When adopting the async APIs you should ensure you provide a compatitble implementation forwillBoot(_:)as well if you want to support older users still running in a non-async context Note your application must be running in an asynchronous context and initialised withmake(_:_:)for this handler to be called
Relationships
Inherits From
Swift.SendableSwift.SendableMetatype