Gracefully shutdown server in case webUI can't be setup (#850)

This commit is contained in:
schroda
2024-01-24 23:49:42 +01:00
committed by GitHub
parent c18cf069b1
commit 285f228660
2 changed files with 11 additions and 1 deletions
@@ -16,6 +16,7 @@ enum class ExitCode(val code: Int) {
Success(0),
MutexCheckFailedTachideskRunning(1),
MutexCheckFailedAnotherAppRunning(2),
WebUISetupFailure(3),
}
fun shutdownApp(exitCode: ExitCode) {
@@ -47,6 +47,7 @@ import suwayomi.tachidesk.graphql.types.WebUIUpdateStatus
import suwayomi.tachidesk.server.ApplicationDirs
import suwayomi.tachidesk.server.generated.BuildConfig
import suwayomi.tachidesk.server.serverConfig
import suwayomi.tachidesk.server.util.ExitCode.WebUISetupFailure
import suwayomi.tachidesk.util.HAScheduler
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@@ -291,7 +292,15 @@ object WebInterfaceManager {
}
logger.warn { "setupWebUI: no webUI files found, starting download..." }
doInitialSetup()
try {
doInitialSetup()
} catch (e: Exception) {
logger.error(e) {
"Failed to setup the webUI. Unable to start the server with a served webUI, change the settings to start" +
"without one. Stopping the server now..."
}
shutdownApp(WebUISetupFailure)
}
}
/**