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 shutdown

LifecycleHandler.swift:28
protocol LifecycleHandler : Sendable
Browse conforming types

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())