Last active
October 15, 2020 14:47
-
-
Save NikkyAI/6cfbaf4416488913cba9950e1076918a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.application.* | |
import io.ktor.server.engine.* | |
import io.ktor.server.netty.* | |
import kotlinx.coroutines.* | |
import java.util.concurrent.TimeUnit | |
// start embedded server and close gracefully | |
fun main(args: Array<String>) { | |
System.setProperty(DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON) | |
val server = embeddedServer( | |
factory = Netty, | |
port = System.getenv("PORT")?.toIntOrNull() ?: 8081, | |
host = System.getenv("HOST") ?: "localhost", | |
watchPaths = listOf("jvm/main"), | |
module = Application::application, | |
configure = { | |
} | |
).start(false) | |
Runtime.getRuntime().addShutdownHook(Thread { | |
server.stop(1, 5, TimeUnit.SECONDS) | |
}) | |
Thread.currentThread().join() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment