You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Graceful: Xorm, RepoIndexer, Cron and Others (#9282)
* Change graceful to use a singleton obtained through GetManager instead of a global.
* Graceful: Make TestPullRequests shutdownable
* Graceful: Make the cron tasks graceful
* Graceful: AddTestPullRequest run in graceful ctx
* Graceful: SyncMirrors shutdown
* Graceful: SetDefaultContext for Xorm to be HammerContext
* Avoid starting graceful for migrate commands and checkout
* Graceful: DeliverHooks now can be shutdown
* Fix multiple syncing errors in modules/sync/UniqueQueue & Make UniqueQueue closable
* Begin the process of making the repo indexer shutdown gracefully
log.Warn("CheckRepoStats: Aborting due to shutdown")
2361
+
return
2362
+
default:
2363
+
repoStatsCheck(ctx, checkers[i])
2364
+
}
2335
2365
}
2336
2366
2337
2367
// ***** START: Repository.NumClosedIssues *****
@@ -2341,6 +2371,12 @@ func CheckRepoStats() {
2341
2371
log.Error("Select %s: %v", desc, err)
2342
2372
} else {
2343
2373
for_, result:=rangeresults {
2374
+
select {
2375
+
case<-ctx.Done():
2376
+
log.Warn("CheckRepoStats: Aborting due to shutdown")
2377
+
return
2378
+
default:
2379
+
}
2344
2380
id:=com.StrTo(result["id"]).MustInt64()
2345
2381
log.Trace("Updating %s: %d", desc, id)
2346
2382
_, err=x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id)
@@ -2358,6 +2394,12 @@ func CheckRepoStats() {
2358
2394
log.Error("Select %s: %v", desc, err)
2359
2395
} else {
2360
2396
for_, result:=rangeresults {
2397
+
select {
2398
+
case<-ctx.Done():
2399
+
log.Warn("CheckRepoStats: Aborting due to shutdown")
2400
+
return
2401
+
default:
2402
+
}
2361
2403
id:=com.StrTo(result["id"]).MustInt64()
2362
2404
log.Trace("Updating %s: %d", desc, id)
2363
2405
_, err=x.Exec("UPDATE `repository` SET num_closed_pulls=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, true, id)
0 commit comments