MCPcopy Create free account
hub / github.com/flant/shell-operator / Start

Method Start

pkg/shell-operator/operator.go:198–227  ·  view source on GitHub ↗

Start runs the operator: opens listeners, primes queues, spawns the metric and event goroutines. It is non-blocking. Calling Start twice is a no-op; the first call's error is returned to subsequent callers.

(_ context.Context)

Source from the content-addressed store, hash-verified

196// and event goroutines. It is non-blocking. Calling Start twice is a no-op;
197// the first call's error is returned to subsequent callers.
198func (op *ShellOperator) Start(_ context.Context) error {
199 op.startOnce.Do(func() {
200 op.logger.Info("start shell-operator")
201
202 if op.APIServer != nil {
203 op.APIServer.Start(op.ctx)
204 }
205
206 if op.TaskQueues != nil {
207 op.bootstrapMainQueue(op.TaskQueues)
208 op.TaskQueues.StartMain(op.ctx)
209 op.initAndStartHookQueues()
210 }
211
212 // Start emit "live" metrics. Goroutines tracked via op.wg so Shutdown
213 // can wait for them.
214 op.runMetrics()
215
216 // Managers generate events. Start the demux loop before informers so
217 // no early Kubernetes event is dropped (#42).
218 if op.ManagerEventsHandler != nil {
219 op.ManagerEventsHandler.Start()
220 }
221
222 if op.ScheduleManager != nil {
223 op.ScheduleManager.Start()
224 }
225 })
226 return op.startErr
227}
228
229// Run is a convenience that Start()s the operator, blocks until ctx is
230// canceled, then performs a synchronous Shutdown with a derived timeout. Use

Callers 1

RunMethod · 0.95

Calls 5

bootstrapMainQueueMethod · 0.95
runMetricsMethod · 0.95
StartMainMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected