Skip to content

Commit

Permalink
fix: watcher now listens for terminal signals
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywolf132 committed Sep 24, 2024
1 parent bdba730 commit e09673c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/watcher/watcher.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package watcher
import (
"github.com/fsnotify/fsnotify"
"os"
"os/signal"
"path/filepath"
"squish/internal/utils"

"squish/pkg/esbuild"
"syscall"
)

type Watcher struct {
Expand Down Expand Up @@ -64,6 +65,16 @@ func (w *Watcher) Watch() error {
return err
}

// Setup signal handling for graceful shutdown
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)

go func() {
<-signals
utils.Log("Received interrupt signal, shutting down watcher...")
close(done)
}()

utils.Log("Watching for changes in", w.srcDir)
<-done
return nil
Expand Down

0 comments on commit e09673c

Please sign in to comment.