Skip to content

Commit

Permalink
Merge pull request #1 from draganm/graceful-shutdown
Browse files Browse the repository at this point in the history
graceful shutdown in SIGINT and SIGTERM
  • Loading branch information
draganm authored Apr 18, 2024
2 parents dda10c3 + 7642a1a commit 16b1b64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"os"
"os/exec"
"os/signal"
"syscall"
"time"

"github.com/draganm/gorefresh/build"
Expand Down Expand Up @@ -39,7 +41,8 @@ func main() {
return fmt.Errorf("module directory is not a directory")
}

ctx := context.Background()
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

eg, ctx := errgroup.WithContext(ctx)

Expand Down Expand Up @@ -188,6 +191,7 @@ func main() {
for {
binary, err := readLast(ctx, binaryChan)
if err != nil {
procCancel()
return fmt.Errorf("failed to get next binary: %w", err)
}

Expand Down

0 comments on commit 16b1b64

Please sign in to comment.