File tree 1 file changed +3
-11
lines changed 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change 6
6
"io"
7
7
"os"
8
8
"strings"
9
- "sync"
10
9
"text/template"
11
10
"time"
12
11
@@ -100,7 +99,6 @@ type ServiceWatchdog interface {
100
99
}
101
100
102
101
func RunWatchdog (manifest * Manifest ) error {
103
- var wg sync.WaitGroup
104
102
watchdogErr := make (chan error , len (manifest .Services ()))
105
103
106
104
output , err := manifest .out .LogOutput ("watchdog" )
@@ -110,23 +108,17 @@ func RunWatchdog(manifest *Manifest) error {
110
108
111
109
for _ , s := range manifest .Services () {
112
110
if watchdogFn , ok := s .component .(ServiceWatchdog ); ok {
113
- wg .Add (1 )
114
-
115
111
go func () {
116
- defer wg .Done ()
117
112
if err := watchdogFn .Watchdog (output , s , context .Background ()); err != nil {
118
113
watchdogErr <- fmt .Errorf ("service %s watchdog failed: %w" , s .Name , err )
119
114
}
120
115
}()
121
116
}
122
117
}
123
- wg .Wait ()
124
118
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 )
130
122
}
131
123
return nil
132
124
}
You can’t perform that action at this time.
0 commit comments