MCPcopy Index your code
hub / github.com/php/frankenphp / initWatchers

Function initWatchers

watcher.go:18–43  ·  view source on GitHub ↗
(o *opt)

Source from the content-addressed store, hash-verified

16var restartWorkers atomic.Bool
17
18func initWatchers(o *opt) error {
19 watchPatterns := make([]*watcher.PatternGroup, 0, len(o.hotReload))
20
21 for _, o := range o.workers {
22 if len(o.watch) == 0 {
23 continue
24 }
25
26 watcherIsEnabled = true
27 watchPatterns = append(watchPatterns, &watcher.PatternGroup{Patterns: o.watch, Callback: func(_ []*watcherGo.Event) {
28 restartWorkers.Store(true)
29 }})
30 }
31
32 if watcherIsEnabled {
33 watchPatterns = append(watchPatterns, &watcher.PatternGroup{
34 Callback: func(_ []*watcherGo.Event) {
35 if restartWorkers.Swap(false) {
36 RestartWorkers()
37 }
38 },
39 })
40 }
41
42 return watcher.InitWatcher(globalCtx, globalLogger, append(watchPatterns, o.hotReload...))
43}
44
45func drainWatchers() {
46 watcher.DrainWatcher()

Callers 1

InitFunction · 0.70

Calls 2

InitWatcherFunction · 0.92
RestartWorkersFunction · 0.85

Tested by

no test coverage detected