aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-05-15 01:06:00 +0100
committerGitHub <noreply@github.com>2020-05-14 20:06:00 -0400
commit4a04740dafb1da047300dfbb9da596fee16af948 (patch)
tree3c2431aba9ca6802787f4b33e5c28bae9518399b /services
parent4159866528e3ceb06d0b7ef1bdb3dc80ce6d0fc4 (diff)
downloadgitea-4a04740dafb1da047300dfbb9da596fee16af948.tar.gz
gitea-4a04740dafb1da047300dfbb9da596fee16af948.zip
Handle panics that percolate up to the graceful module (#11291)
* Handle panics in graceful goroutines Adds a some deferred functions to handle panics in graceful goroutines Signed-off-by: Andrew Thornton <art27@cantab.net> * Handle panic in webhook.Deliver Signed-off-by: Andrew Thornton <art27@cantab.net> * Handle panic in mirror.syncMirror Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services')
-rw-r--r--services/mirror/mirror.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index e870364918..82d8fc59b2 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -333,6 +333,14 @@ func SyncMirrors(ctx context.Context) {
func syncMirror(repoID string) {
log.Trace("SyncMirrors [repo_id: %v]", repoID)
+ defer func() {
+ err := recover()
+ if err == nil {
+ return
+ }
+ // There was a panic whilst syncMirrors...
+ log.Error("PANIC whilst syncMirrors[%s] Panic: %v\nStacktrace: %s", repoID, err, log.Stack(2))
+ }()
mirrorQueue.Remove(repoID)
m, err := models.GetMirrorByRepoID(com.StrTo(repoID).MustInt64())