Skip to content

Commit e09673c

Browse files
committed
fix: watcher now listens for terminal signals
1 parent bdba730 commit e09673c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/watcher/watcher.go

100644100755
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package watcher
33
import (
44
"github.com/fsnotify/fsnotify"
55
"os"
6+
"os/signal"
67
"path/filepath"
78
"squish/internal/utils"
8-
99
"squish/pkg/esbuild"
10+
"syscall"
1011
)
1112

1213
type Watcher struct {
@@ -64,6 +65,16 @@ func (w *Watcher) Watch() error {
6465
return err
6566
}
6667

68+
// Setup signal handling for graceful shutdown
69+
signals := make(chan os.Signal, 1)
70+
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
71+
72+
go func() {
73+
<-signals
74+
utils.Log("Received interrupt signal, shutting down watcher...")
75+
close(done)
76+
}()
77+
6778
utils.Log("Watching for changes in", w.srcDir)
6879
<-done
6980
return nil

0 commit comments

Comments
 (0)