Stop Javalin properly on shutdown (#69)

This commit is contained in:
Syer10 2021-05-03 12:10:02 -04:00 committed by GitHub
parent 59cbe5d5bc
commit 1dd029559e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,7 @@ import java.io.IOException
import java.text.SimpleDateFormat
import java.util.Date
import java.util.concurrent.CompletableFuture
import kotlin.concurrent.thread
/*
* Copyright (C) Contributors to the Suwayomi project
@ -75,6 +76,13 @@ object JavalinSetup {
}
config.enableCorsForAllOrigins()
}.start(serverConfig.ip, serverConfig.port)
Runtime.getRuntime().addShutdownHook(
thread(start = false) {
app.stop()
}
)
if (hasWebUiBundled && serverConfig.initialOpenInBrowserEnabled) {
openInBrowser()
}