Skip to content

Commit aa3682d

Browse files
authored
Merge pull request #7 from civo/fix/improve-starter-logic
Bugfix for starter logic
2 parents f700a3c + b8005f0 commit aa3682d

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

main.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88
"os/signal"
99
"strings"
10-
"sync"
1110
"syscall"
1211

1312
"github.com/civo/node-agent/pkg/watcher"
@@ -25,22 +24,8 @@ var (
2524
)
2625

2726
func run(ctx context.Context) error {
28-
ctx, cancel := context.WithCancel(ctx)
29-
defer cancel()
30-
31-
wg := new(sync.WaitGroup)
32-
defer wg.Wait()
33-
34-
c := make(chan os.Signal, 1)
35-
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
36-
defer signal.Stop(c)
37-
38-
wg.Add(1)
39-
go func() {
40-
defer wg.Done()
41-
<-c
42-
cancel()
43-
}()
27+
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
28+
defer stop()
4429

4530
w, err := watcher.NewWatcher(ctx, apiURL, apiKey, region, clusterID, nodePoolID, nodeDesiredGPUCount)
4631
if err != nil {

0 commit comments

Comments
 (0)