Skip to content

Commit

Permalink
Actually commit that
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Keller committed Feb 7, 2019
1 parent c0a5448 commit 341bbd9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,6 +16,7 @@ room_*_stackexchange.com.json
room_*_meta.stackexchange.com.json room_*_meta.stackexchange.com.json
reports.json reports.json
location.txt location.txt
/Packages


# Ignore swap files; I use vim. # Ignore swap files; I use vim.
*.sw[klmnop] *.sw[klmnop]
15 changes: 14 additions & 1 deletion Sources/Frontend/BackgroundTasks.swift
Expand Up @@ -85,6 +85,9 @@ func handleInput(input: String, rooms: [ChatRoom], listener: ChatListener) {
) )
} }


let maxRedundaErrors = 3
var redundaErrorCount = 0



func scheduleBackgroundTasks(rooms: [ChatRoom], listener: ChatListener) { func scheduleBackgroundTasks(rooms: [ChatRoom], listener: ChatListener) {
BackgroundTaskManager.shared.tasks = [ BackgroundTaskManager.shared.tasks = [
Expand Down Expand Up @@ -163,11 +166,21 @@ func scheduleBackgroundTasks(rooms: [ChatRoom], listener: ChatListener) {
listener.stop(.reboot) listener.stop(.reboot)
} }


if redundaErrorCount >= maxRedundaErrors {
rooms.first!.postMessage("[ [\(botName)](\(githubLink)) ] Redunda appears to be back up (cc @NobodyNada).")
}
redundaErrorCount = 0

if let commit = ciVersion ?? updateVersion { if let commit = ciVersion ?? updateVersion {
_ = update(to: commit, listener: listener, rooms: [rooms.first!]) _ = update(to: commit, listener: listener, rooms: [rooms.first!])
} }
} catch { } catch {
handleError(error, "while sending a status ping to Redunda") redundaErrorCount += 1
if redundaErrorCount == maxRedundaErrors {
rooms.first!.postMessage("[ [\(botName)](\(githubLink)) ] Redunda appears to be down; silencing errors (cc @NobodyNada).")
} else if redundaErrorCount < maxRedundaErrors {
handleError(error, "while sending a status ping to Redunda")
}
} }
} }
] ]
Expand Down

0 comments on commit 341bbd9

Please sign in to comment.