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)
| 722 | // function does not access rawCfg, that lock |
| 723 | // synchronizes the stop/start of apps. |
| 724 | func 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. |
no test coverage detected