MCPcopy
hub / github.com/caddyserver/caddy / unsyncedStop

Function unsyncedStop

caddy.go:724–742  ·  view source on GitHub ↗

unsyncedStop stops ctx from running, but has no locking around ctx. It is a no-op if ctx has a nil cfg. If any app returns an error when stopping, it is logged and the function continues stopping the next app. This function assumes all apps in ctx were successfully started first. A lock on rawCfgMu

(ctx Context)

Source from the content-addressed store, hash-verified

722// function does not access rawCfg, that lock
723// synchronizes the stop/start of apps.
724func unsyncedStop(ctx Context) {
725 if ctx.cfg == nil {
726 return
727 }
728
729 // TODO: This event is experimental and subject to change.
730 ctx.emitEvent("stopping", nil)
731
732 // stop each app
733 for name, a := range ctx.cfg.apps {
734 err := a.Stop()
735 if err != nil {
736 log.Printf("[ERROR] stop %s: %v", name, err)
737 }
738 }
739
740 // clean up all modules
741 ctx.cfg.cancelFunc(fmt.Errorf("stopping apps"))
742}
743
744// Validate loads, provisions, and validates
745// cfg, but does not start running it.

Callers 2

unsyncedDecodeAndRunFunction · 0.85
StopFunction · 0.85

Calls 2

emitEventMethod · 0.80
StopMethod · 0.65

Tested by

no test coverage detected