From 4b273c6bf92116e9af3ad4b3ccf70fd97bc7ff11 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Mon, 3 May 2021 20:48:29 +0430 Subject: [PATCH] add a bit of docs --- .../kotlin/ir/armor/tachidesk/server/JavalinSetup.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt index 0164cb2..2eabda5 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt @@ -66,7 +66,10 @@ object JavalinSetup { val app = Javalin.create { config -> try { + // if the bellow line throws an exception then webUI is not bundled Main::class.java.getResource("/react/index.html") + + // no exception so we can tell javalin to serve webUI hasWebUiBundled = true config.addStaticFiles("/react") config.addSinglePageRoot("/", "/react/index.html") @@ -77,10 +80,11 @@ object JavalinSetup { config.enableCorsForAllOrigins() }.start(serverConfig.ip, serverConfig.port) + // when JVM is prompted to shutdown, stop javalin gracefully Runtime.getRuntime().addShutdownHook( - thread(start = false) { - app.stop() - } + thread(start = false) { + app.stop() + } ) if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {