この機能は、アクセスした際にサーバをシャットダウンさせるURLを有効にする機能です。
HOCONを使って自動設定する方法とFeatureをインストールする方法の2つの方法があります。
io.ktor.server.engine.ShutDownUrl.ApplicationCallFeature
in the artifact io.ktor:ktor-server-host-common:$ktor_version
.
dependencies {
implementation "io.ktor:ktor-server-host-common:$ktor_version"
}
dependencies {
implementation("io.ktor:ktor-server-host-common:$ktor_version")
}
<project>
...
<dependencies>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-host-common</artifactId>
<version>${ktor.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
HOCONファイルのktor.deployment.shutdown.urlプロパティを使って、 シャットダウンURLを設定することができます。
ktor {
deployment {
shutdown.url = "/my/shutdown/path"
}
}
ShutDownUrl.ApplicationCallFeature
を使い、shutDownUrl
とexitCodeSupplier
をセットすることで、
Featureを手動でインストールすることができます。
install(ShutDownUrl.ApplicationCallFeature) {
// The URL that will be intercepted
shutDownUrl = "/ktor/application/shutdown"
// A function that will be executed to get the exit code of the process
exitCodeSupplier = { 0 } // ApplicationCall.() -> Int
}