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

Method Shutdown

provisionerd/provisionerd.go:644–663  ·  view source on GitHub ↗

Shutdown gracefully exists with the option to cancel the active job. If false, it will wait for the job to complete. nolint:revive

(ctx context.Context, cancelActiveJob bool)

Source from the content-addressed store, hash-verified

642//
643//nolint:revive
644func (p *Server) Shutdown(ctx context.Context, cancelActiveJob bool) error {
645 p.mutex.Lock()
646 p.opts.Logger.Info(ctx, "attempting graceful shutdown")
647 if !p.shuttingDownB {
648 close(p.shuttingDownCh)
649 p.shuttingDownB = true
650 }
651 if cancelActiveJob && p.activeJob != nil {
652 p.activeJob.Cancel()
653 }
654 p.mutex.Unlock()
655 select {
656 case <-ctx.Done():
657 p.opts.Logger.Warn(ctx, "graceful shutdown failed", slog.Error(ctx.Err()))
658 return ctx.Err()
659 case <-p.acquireDoneCh:
660 p.opts.Logger.Info(ctx, "gracefully shutdown")
661 return nil
662 }
663}
664
665// Close ends the provisioner. It will mark any running jobs as failed.
666func (p *Server) Close() error {

Callers

nothing calls this directly

Calls 7

ErrMethod · 0.80
LockMethod · 0.45
InfoMethod · 0.45
CancelMethod · 0.45
UnlockMethod · 0.45
DoneMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected