Server Plugin
關機網址
程式碼範例: shutdown-url
ShutDownUrl 外掛程式允許您配置一個用於關閉伺服器的網址。 有兩種方式可以啟用此外掛程式:
在設定檔中配置關機網址
您可以在 設定檔 中使用 ktor.deployment.shutdown.url 屬性來配置關機網址。
shell
ktor {
deployment {
shutdown.url = "/shutdown"
}
}
yaml
ktor:
deployment:
shutdown:
url: "/shutdown"
透過安裝外掛程式配置關機網址
若要 安裝 並在程式碼中配置關機網址,請將 ShutDownUrl.ApplicationCallPlugin
傳遞給 install
函數並使用 shutDownUrl
屬性:
kotlin
install(ShutDownUrl.ApplicationCallPlugin) {
shutDownUrl = "/shutdown"
exitCodeSupplier = { 0 }
}
完整的範例請參閱 shutdown-url。