MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / Shutdown

Method Shutdown

pkg/queue/queue.go:134–156  ·  view source on GitHub ↗

Shutdown stops all queues.

()

Source from the content-addressed store, hash-verified

132
133// Shutdown stops all queues.
134func (q *queue) Shutdown() {
135 q.logger.Info("Shutting down queue %q...", q.name)
136 defer func() {
137 q.routineGroup.Wait()
138 }()
139
140 if !atomic.CompareAndSwapInt32(&q.stopFlag, 0, 1) {
141 return
142 }
143
144 q.stopOnce.Do(func() {
145 q.cancel()
146 if q.metric.BusyWorkers() > 0 {
147 q.logger.Info("shutdown all tasks in queue %q: %d workers", q.name, q.metric.BusyWorkers())
148 }
149
150 if err := q.scheduler.Shutdown(); err != nil {
151 q.logger.Error("failed to shutdown scheduler in queue %q: %w", q.name, err)
152 }
153 close(q.quit)
154 })
155
156}
157
158// BusyWorkers returns the numbers of workers in the running process.
159func (q *queue) BusyWorkers() int {

Callers

nothing calls this directly

Calls 6

WaitMethod · 0.80
InfoMethod · 0.65
DoMethod · 0.65
BusyWorkersMethod · 0.65
ShutdownMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected