This feature enables a URL that when accessed, shutdowns the server.
There are two ways to use it: Automatically using HOCON and Installing the feature
io.ktor:ktor-server-host-common:$ktor_version
中的
io.ktor.server.engine.ShutDownUrl.ApplicationCallFeature
类中定义。
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>
You can configure a shutdown URL using HOCON with the ktor.deployment.shutdown.url property.
ktor {
deployment {
shutdown.url = "/my/shutdown/path"
}
}
You can manually install the feature, with ShutDownUrl.ApplicationCallFeature
and set the shutDownUrl
and an exitCodeSupplier
:
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
}