mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
Fix/missed automated task execution failure crashes server on startup (#1019)
* Catch automated backup task errors * Catch automated udpate task errors * Catch automated webui update task errors
This commit is contained in:
@@ -84,9 +84,13 @@ object ProtoBackupExport : ProtoBackupBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val task = {
|
val task = {
|
||||||
|
try {
|
||||||
cleanupAutomatedBackups()
|
cleanupAutomatedBackups()
|
||||||
createAutomatedBackup()
|
createAutomatedBackup()
|
||||||
preferences.edit().putLong(LAST_AUTOMATED_BACKUP_KEY, System.currentTimeMillis()).apply()
|
preferences.edit().putLong(LAST_AUTOMATED_BACKUP_KEY, System.currentTimeMillis()).apply()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.error(e) { "scheduleAutomatedBackupTask: failed due to" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val (hour, minute) = serverConfig.backupTime.value.split(":").map { it.toInt() }
|
val (hour, minute) = serverConfig.backupTime.value.split(":").map { it.toInt() }
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class Updater : IUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun autoUpdateTask() {
|
private fun autoUpdateTask() {
|
||||||
|
try {
|
||||||
val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0)
|
val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0)
|
||||||
preferences.edit().putLong(lastAutomatedUpdateKey, System.currentTimeMillis()).apply()
|
preferences.edit().putLong(lastAutomatedUpdateKey, System.currentTimeMillis()).apply()
|
||||||
|
|
||||||
@@ -124,6 +125,9 @@ class Updater : IUpdater {
|
|||||||
)})"
|
)})"
|
||||||
}
|
}
|
||||||
addCategoriesToUpdateQueue(Category.getCategoryList(), clear = true, forceAll = false)
|
addCategoriesToUpdateQueue(Category.getCategoryList(), clear = true, forceAll = false)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.error(e) { "autoUpdateTask: failed due to" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
|
|||||||
@@ -249,8 +249,9 @@ object WebInterfaceManager {
|
|||||||
val lastAutomatedUpdate = preferences.getLong(LAST_WEBUI_UPDATE_CHECK_KEY, System.currentTimeMillis())
|
val lastAutomatedUpdate = preferences.getLong(LAST_WEBUI_UPDATE_CHECK_KEY, System.currentTimeMillis())
|
||||||
|
|
||||||
val task = {
|
val task = {
|
||||||
logger.debug {
|
val log =
|
||||||
"Checking for webUI update (" +
|
KotlinLogging.logger(
|
||||||
|
"${logger.name}::scheduleWebUIUpdateCheck(" +
|
||||||
"flavor= ${WebUIFlavor.current.uiName}, " +
|
"flavor= ${WebUIFlavor.current.uiName}, " +
|
||||||
"channel= ${serverConfig.webUIChannel.value}, " +
|
"channel= ${serverConfig.webUIChannel.value}, " +
|
||||||
"interval= ${serverConfig.webUIUpdateCheckInterval.value}h, " +
|
"interval= ${serverConfig.webUIUpdateCheckInterval.value}h, " +
|
||||||
@@ -258,11 +259,16 @@ object WebInterfaceManager {
|
|||||||
Date(
|
Date(
|
||||||
lastAutomatedUpdate,
|
lastAutomatedUpdate,
|
||||||
)
|
)
|
||||||
})"
|
})",
|
||||||
}
|
)
|
||||||
|
log.debug { "called" }
|
||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
|
try {
|
||||||
checkForUpdate(WebUIFlavor.current)
|
checkForUpdate(WebUIFlavor.current)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
log.error(e) { "failed due to" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user