Pavel Kunyavskiy [JB]
10/12/2022, 8:42 PMSystem.exit() , but that's looks too rude way to stop. Maybe you have some better way to do that?PHondogo
10/13/2022, 4:45 AMsimon.vergauwen
10/13/2022, 6:11 AMembeddedServer which runs on a CoroutineScope which is then the parent of Application : SupervisorJob so if you can the outer CoroutineScope it also stop the Applicationsimon.vergauwen
10/13/2022, 6:12 AMcoroutineScope parent@ {
val engine = embeddedServer(...) {
// use parent
}
// use parent
// awaitCancellation()
//engine.start(wait = true)
}simon.vergauwen
10/13/2022, 6:12 AMrunBlocking can be a replacement for coroutineScope here as well depending on where you need to actually launch this codePavel Kunyavskiy [JB]
10/13/2022, 6:55 AMsimon.vergauwen
10/13/2022, 7:04 AMEngineMain you lose control over how the server is started, and thus its lifecycle.
Ktor has some support to still rely on file config, but never used it https://ktor.io/docs/configurations.html#embedded-custom
I mostly rely on manual configuration, like this https://github.com/nomisRev/ktor-arrow-example/blob/main/src/main/kotlin/io/github/nomisrev/env/Env.kt
And I've also used the hoplite library, https://github.com/sksamuel/hopliteEmil Kantis
10/13/2022, 11:53 AM