Partho Paul
09/19/2022, 3:11 PMfun main(args: Array<String>): Unit = runBlocking(Dispatchers.Default) {
embeddedServer(
Netty,
) { module() }.awaitShutdown()
}
fun Application.module(testing: Boolean = false) {
configureMonitoring()
configureRouting()
configureSerialization()
configureHTTP()
configureKoin()
statusPage()
}
But I’m not sure where to pass the args from conf file. I know I can use fun main(args: Array<String>): Unit = EngineMain.main(args)
instead of embeddedServer but I’m not sure I can add custom shutdown hook to it. Can someone please help me for this?August Lilleaas
09/19/2022, 5:46 PMPartho Paul
09/20/2022, 4:51 AMEngineMain.main(args)
implementation, I’m able to read the config via environment.config.property(key).getString()
. Using the same for embeddedServer is not working and is throwing io.ktor.server.config.ApplicationConfigurationException: Property ktor.api.customkey not found
August Lilleaas
09/20/2022, 6:40 AMAugust Lilleaas
09/20/2022, 6:40 AMPartho Paul
09/20/2022, 9:29 AMval environment = applicationEngineEnvironment {
this.parentCoroutineContext = coroutineContext + parentCoroutineContext
this.log = KtorSimpleLogger("ktor.application")
this.connectors.addAll(connectors)
this.config = HoconApplicationConfig(ConfigFactory.load())
}
embeddedServer(factory, environment, configure).apply { start() }