File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change 66 "io"
77 "os"
88 "strings"
9- "sync"
109 "text/template"
1110 "time"
1211
@@ -100,7 +99,6 @@ type ServiceWatchdog interface {
10099}
101100
102101func RunWatchdog (manifest * Manifest ) error {
103- var wg sync.WaitGroup
104102 watchdogErr := make (chan error , len (manifest .Services ()))
105103
106104 output , err := manifest .out .LogOutput ("watchdog" )
@@ -110,23 +108,17 @@ func RunWatchdog(manifest *Manifest) error {
110108
111109 for _ , s := range manifest .Services () {
112110 if watchdogFn , ok := s .component .(ServiceWatchdog ); ok {
113- wg .Add (1 )
114-
115111 go func () {
116- defer wg .Done ()
117112 if err := watchdogFn .Watchdog (output , s , context .Background ()); err != nil {
118113 watchdogErr <- fmt .Errorf ("service %s watchdog failed: %w" , s .Name , err )
119114 }
120115 }()
121116 }
122117 }
123- wg .Wait ()
124118
125- close (watchdogErr )
126- for err := range watchdogErr {
127- if err != nil {
128- return err
129- }
119+ // If any of the watchdogs fail, we return the error
120+ if err := <- watchdogErr ; err != nil {
121+ return fmt .Errorf ("failed to run watchdog: %w" , err )
130122 }
131123 return nil
132124}
You can’t perform that action at this time.
0 commit comments