diff options
Diffstat (limited to 'routers/web/admin/queue_tester.go')
-rw-r--r-- | routers/web/admin/queue_tester.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/routers/web/admin/queue_tester.go b/routers/web/admin/queue_tester.go index 96373c4d5f..8f713b3bb1 100644 --- a/routers/web/admin/queue_tester.go +++ b/routers/web/admin/queue_tester.go @@ -4,12 +4,13 @@ package admin import ( - gocontext "context" + "runtime/pprof" "sync" "time" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/queue" "code.gitea.io/gitea/modules/setting" ) @@ -21,6 +22,7 @@ var testQueueOnce sync.Once // developers could see the queue length / worker number / items number on the admin page and try to remove the items func initTestQueueOnce() { testQueueOnce.Do(func() { + ctx, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().ShutdownContext(), "TestQueue", process.SystemProcessType, false) qs := setting.QueueSettings{ Name: "test-queue", Type: "channel", @@ -28,7 +30,7 @@ func initTestQueueOnce() { BatchLength: 2, MaxWorkers: 3, } - testQueue, err := queue.NewWorkerPoolQueueBySetting("test-queue", qs, func(t ...int64) (unhandled []int64) { + testQueue, err := queue.NewWorkerPoolQueueWithContext(ctx, "test-queue", qs, func(t ...int64) (unhandled []int64) { for range t { select { case <-graceful.GetManager().ShutdownContext().Done(): @@ -44,8 +46,11 @@ func initTestQueueOnce() { queue.GetManager().AddManagedQueue(testQueue) testQueue.SetWorkerMaxNumber(5) - go graceful.GetManager().RunWithShutdownFns(testQueue.Run) - go graceful.GetManager().RunWithShutdownContext(func(ctx gocontext.Context) { + go graceful.GetManager().RunWithCancel(testQueue) + go func() { + pprof.SetGoroutineLabels(ctx) + defer finished() + cnt := int64(0) adding := true for { @@ -67,6 +72,6 @@ func initTestQueueOnce() { } } } - }) + }() }) } |