Skip to content

Fix watchdog #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions internal/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"
"strings"
"sync"
"text/template"
"time"

Expand Down Expand Up @@ -100,7 +99,6 @@ type ServiceWatchdog interface {
}

func RunWatchdog(manifest *Manifest) error {
var wg sync.WaitGroup
watchdogErr := make(chan error, len(manifest.Services()))

output, err := manifest.out.LogOutput("watchdog")
Expand All @@ -110,23 +108,17 @@ func RunWatchdog(manifest *Manifest) error {

for _, s := range manifest.Services() {
if watchdogFn, ok := s.component.(ServiceWatchdog); ok {
wg.Add(1)

go func() {
defer wg.Done()
if err := watchdogFn.Watchdog(output, s, context.Background()); err != nil {
watchdogErr <- fmt.Errorf("service %s watchdog failed: %w", s.Name, err)
}
}()
}
}
wg.Wait()

close(watchdogErr)
for err := range watchdogErr {
if err != nil {
return err
}
// If any of the watchdogs fail, we return the error
if err := <-watchdogErr; err != nil {
return fmt.Errorf("failed to run watchdog: %w", err)
}
return nil
}
Expand Down