https://kotlinlang.org logo
Title
z

zero_coding

08/28/2020, 12:06 PM
Hi all I am trying to enable autoreload function and I have tried as follows:
ktor {
    deployment {
        port = 8080
        port = ${?PORT}
        watch = [ user-svc ]
    }
    application {
        modules = [ io.databaker.ApplicationKt.module ]
    }
}
n

Nikky

08/30/2020, 11:54 AM
watch matches against classloader names.. not your src folder.. unelss your project is named like that PS: misread svc as
src
on a bad screen
i use his to start ktor:
fun runKtor() {
    val server = embeddedServer(
        factory = Netty,
        port = System.getenv("PORT")?.toIntOrNull() ?: 8080,
        host = System.getenv("HOST") ?: "127.0.0.1",
        watchPaths = listOf("jvm/main"),
        module = Application::application,
        configure = {

        }
    ).start(false)

    Runtime.getRuntime().addShutdownHook(Thread {
        server.stop(1, 5, TimeUnit.SECONDS)
    })
    Thread.currentThread().join()
}
this also handles shutdown gracefully
your classloader will have the path to the location of the class files so something like
~/projects/projectName/build/classes/kotlin/jvm/main
which is why i just match on
jvm/main
and it works well