MCPcopy Index your code
hub / github.com/coder/coder / Start

Method Start

coderd/jobreaper/detector.go:142–169  ·  view source on GitHub ↗

Start will cause the detector to detect and unhang provisioner jobs on every tick from its channel. It will stop when its context is Done, or when its channel is closed. Start should only be called once.

()

Source from the content-addressed store, hash-verified

140//
141// Start should only be called once.
142func (d *Detector) Start() {
143 go func() {
144 defer close(d.done)
145 defer d.cancel()
146
147 for {
148 select {
149 case <-d.ctx.Done():
150 return
151 case t, ok := <-d.tick:
152 if !ok {
153 return
154 }
155 stats := d.run(t)
156 if stats.Error != nil && !xerrors.As(stats.Error, &acquireLockError{}) {
157 d.log.Warn(d.ctx, "error running workspace build hang detector once", slog.Error(stats.Error))
158 }
159 if d.stats != nil {
160 select {
161 case <-d.ctx.Done():
162 return
163 case d.stats <- stats:
164 }
165 }
166 }
167 }
168 }()
169}
170
171// Wait will block until the detector is stopped.
172func (d *Detector) Wait() {

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
AsMethod · 0.80
cancelMethod · 0.45
DoneMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected