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

Method Run

coderd/autobuild/lifecycle_executor.go:112–135  ·  view source on GitHub ↗

Run will cause executor to start or stop workspaces on every tick from its channel. It will stop when its context is Done, or when its channel is closed.

()

Source from the content-addressed store, hash-verified

110// tick from its channel. It will stop when its context is Done, or when
111// its channel is closed.
112func (e *Executor) Run() {
113 pproflabel.Go(e.ctx, pproflabel.Service(pproflabel.ServiceLifecycles), func(ctx context.Context) {
114 for {
115 select {
116 case <-ctx.Done():
117 return
118 case t, ok := <-e.tick:
119 if !ok {
120 return
121 }
122 stats := e.runOnce(t)
123 e.metrics.autobuildExecutionDuration.Observe(stats.Elapsed.Seconds())
124 if e.statsCh != nil {
125 select {
126 case <-ctx.Done():
127 return
128 case e.statsCh <- stats:
129 }
130 }
131 e.log.Debug(ctx, "run stats", slog.F("elapsed", stats.Elapsed), slog.F("transitions", stats.Transitions))
132 }
133 }
134 })
135}
136
137// hasValidProvisioner checks whether there is at least one valid (non-stale, correct tags) provisioner
138// based on time t and the tags maps (such as from a templateVersionJob).

Callers 1

ServerMethod · 0.95

Calls 4

runOnceMethod · 0.95
GoFunction · 0.92
ServiceFunction · 0.92
DoneMethod · 0.45

Tested by

no test coverage detected