I guess I'll need the full repo around as a refere...
# ktor
d
I guess I'll need the full repo around as a reference in the future...
d
Why? I mean, at least with gradle you can see the source code and kdocs for any symbol just by
ctrl/cmd+click
d
I can go as far as EmbeddedServer.kt, but can't go into TEngine...
Also on start() there's no docs I see
d
Let me check
I see. That’s because the documentation is part of the interface that NettyApplicationEngine implements. If you are using the interface it works.

http://oi63.tinypic.com/2a4twsk.jpg

Going to see if we can improve this
d
Thanks! btw, if I do the setup of
start(false)
,
start(true)
, if the second one fails for any reason, the first one will also go down? Would there be a fault tolerant way of keeping any healthy one alive?
👀 1
d
Untested, but maybe something like this?
Copy code
fun main(args: Array<String>) {
    val engineApi = embeddedServer(Netty, port = 8080, module = Application::apiModule)
    val engineInternal = embeddedServer(Netty, port = 9090, module = Application::internalModule)

    val engineApiStopDeferred = CompletableDeferred<Unit>()
    val engineInternalStopDeferred = CompletableDeferred<Unit>()

    engineApi.environment.monitor.subscribe(ApplicationStopped) { engineApiStopDeferred.complete(Unit) }
    engineInternal.environment.monitor.subscribe(ApplicationStopped) { engineInternalStopDeferred.complete(Unit)  }

    try { engineApi.start(wait = false) } catch (e: Throwable) { e.printStackTrace() }
    try { engineInternal.start(wait = false) } catch (e: Throwable) { e.printStackTrace() }

    runBlocking {
        engineApiStopDeferred.await()
        engineInternalStopDeferred.await()
    }
}
d
Interesting... this might be a nice solution also regarding my problem w/ Docker.. but I'd just have to implement the last part a bit differently... thanks!
The only problem is where to put the health check... 😞