Extend lifecycle handler example (#843)

Server lifecycle has been extended with `didBoot` and `shutdown` events. Extend lifecycle handler example.
This commit is contained in:
František Mikš 2023-07-11 23:12:47 +02:00 committed by GitHub
parent f6b4271e69
commit 871eab9b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View File

@ -82,6 +82,16 @@ struct Hello: LifecycleHandler {
func willBoot(_ app: Application) throws {
app.logger.info("Hello!")
}
// Called after application boots.
func didBoot(_ app: Application) throws {
app.logger.info("Server is running")
}
// Called before application shutdown.
func shutdown(_ app: Application) {
app.logger.info("Goodbye!")
}
}
// Add lifecycle handler.

View File

@ -81,6 +81,16 @@ struct Hello: LifecycleHandler {
func willBoot(_ app: Application) throws {
app.logger.info("Hello!")
}
// Wordt aangeroepen nadat de applicatie is opgestart.
func didBoot(_ app: Application) throws {
app.logger.info("Server is running")
}
// Wordt aangeroepen voordat de applicatie wordt afgesloten.
func shutdown(_ app: Application) {
app.logger.info("Goodbye!")
}
}
// Voeg levenscyclus handler toe.

View File

@ -81,6 +81,16 @@ struct Hello: LifecycleHandler {
func willBoot(_ app: Application) throws {
app.logger.info("Hello!")
}
// 应用程序启动后调用。
func didBoot(_ app: Application) throws {
app.logger.info("Server is running")
}
// 在应用程序关闭前调用。
func shutdown(_ app: Application) {
app.logger.info("Goodbye!")
}
}
// 添加生命周期处理程序。