Skip to content

Instantly share code, notes, and snippets.

@lankydan lankydan/Server.kt
Created Aug 12, 2019

Embed
What would you like to do?
Corda + Ktor - gracefully disconnecting from node
fun NettyApplicationEngine.addShutdownHook() {
Runtime.getRuntime().addShutdownHook(Thread {
stop(1, 1, TimeUnit.SECONDS)
})
Thread.currentThread().join()
}
fun Application.addShutdownEvent(connection: CordaRPCConnection) {
environment.monitor.subscribe(ApplicationStopped) {
connection.notifyServerAndClose()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.