mirror of
https://github.com/Luzifer/elb-instance-status.git
synced 2025-01-10 11:41:56 +00:00
Compare commits
No commits in common. "84df5e9f1aaabbf73ff6a7a006a61d2f48871f4c" and "879faa0a3685c83b9b82b595e2b42ca4e29ad9b0" have entirely different histories.
84df5e9f1a
...
879faa0a36
2 changed files with 2 additions and 20 deletions
|
@ -1,7 +1,3 @@
|
||||||
# 1.1.2 / 2024-04-20
|
|
||||||
|
|
||||||
* Fix: Cleanup context after checks have run
|
|
||||||
|
|
||||||
# 1.1.1 / 2024-04-19
|
# 1.1.1 / 2024-04-19
|
||||||
|
|
||||||
* Update dependencies
|
* Update dependencies
|
||||||
|
|
18
checks.go
18
checks.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -144,22 +143,9 @@ func loadChecks() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func spawnChecks() {
|
func spawnChecks() {
|
||||||
var wg sync.WaitGroup
|
ctx, _ := context.WithTimeout(context.Background(), cfg.CheckInterval-time.Second)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), cfg.CheckInterval-time.Second)
|
|
||||||
|
|
||||||
wg.Add(len(checks))
|
|
||||||
go func() {
|
|
||||||
// Do not block the execution function but cleanup the context after
|
|
||||||
// all checks are done (or cancelled)
|
|
||||||
wg.Wait()
|
|
||||||
cancel()
|
|
||||||
}()
|
|
||||||
|
|
||||||
for id := range checks {
|
for id := range checks {
|
||||||
go func(ctx context.Context, id string) {
|
go executeAndRegisterCheck(ctx, id)
|
||||||
defer wg.Done()
|
|
||||||
executeAndRegisterCheck(ctx, id)
|
|
||||||
}(ctx, id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue