Skip to content

Commit

Permalink
Gracefully shutdown server in case webUI can't be setup (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda authored Jan 24, 2024
1 parent c18cf06 commit 285f228
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum class ExitCode(val code: Int) {
Success(0),
MutexCheckFailedTachideskRunning(1),
MutexCheckFailedAnotherAppRunning(2),
WebUISetupFailure(3),
}

fun shutdownApp(exitCode: ExitCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

/**
Expand Down

0 comments on commit 285f228

Please sign in to comment.