https://kotlinlang.org logo
Title
n

Nick

08/13/2019, 8:27 PM
Hello everyone! If I subscribe to the environment monitor like
environment.monitor.subscribe(ApplicationStarted)
every time hot-reload happens it will subscribe one more function subscribed call. is this behaviour normal?
example
environment.monitor.subscribe(ApplicationStarted) {
        print("hi")
    }
outputs first load
hi15:30:45.022 [main] TRACE ktor.application - Application started: io.ktor.application.Application@1ad926d3
second load (hot-reload)
hihi16:24:00.587 [nioEventLoopGroup-3-1] TRACE ktor.application - Application started: io.ktor.application.Application@353d7adb
s

Sergey Bondari

08/13/2019, 11:01 PM
out of curiosity, is ApplicationStopped also called?
n

Nick

08/14/2019, 12:00 AM
hihi19:59:50.527 [nioEventLoopGroup-3-1] TRACE ktor.application - Application stopped: io.ktor.application.Application@244b9b58
it is called
environment.monitor
is the same instance between restarts
s

Sergey Bondari

08/15/2019, 10:23 PM
It looks like it is working as designed then. I would expect a sane app server to restart if I reload a random class.