Add an URL for shutting down the server

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

This feature is defined in the class 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>

Automatically using HOCON

You can configure a shutdown URL using HOCON with the ktor.deployment.shutdown.url property.

1. ktor {
2. deployment {
3. shutdown.url = "/my/shutdown/path"
4. }
5. }

Installing the feature

You can manually install the feature, with ShutDownUrl.ApplicationCallFeature and set the shutDownUrl and an exitCodeSupplier:

1. install(ShutDownUrl.ApplicationCallFeature) {
2. // The URL that will be intercepted
3. shutDownUrl = "/ktor/application/shutdown"
4. // A function that will be executed to get the exit code of the process
5. exitCodeSupplier = { 0 } // ApplicationCall.() -> Int
6. }