Skip to content

Commit 76d04c5

Browse files
committed
fix: fixes re-spawning of processes upon exit
1 parent 54ae2d2 commit 76d04c5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

main.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func main() {
151151

152152
go func() {
153153
<-ctx.Done()
154-
logger.Debug("fwatcher is closing 2...")
155154
watcher.Close()
156155
<-time.After(200 * time.Millisecond)
157156
os.Exit(0)
@@ -169,9 +168,16 @@ func main() {
169168
}
170169
logger.Info(fmt.Sprintf("[RELOADING] due changes in %s", relPath))
171170
ex.Kill()
172-
<-time.After(100 * time.Millisecond)
173-
go ex.Exec()
174-
return nil
171+
172+
select {
173+
case <-time.After(100 * time.Millisecond):
174+
go ex.Exec()
175+
return nil
176+
case <-ctx.Done():
177+
logger.Info("close signal received")
178+
watcher.Close()
179+
return nil
180+
}
175181
})
176182

177183
return nil

pkg/watcher/watcher.go

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func NewWatcher(ctx context.Context, args WatcherArgs) (Watcher, error) {
229229

230230
excludeDirs := map[string]struct{}{}
231231
for _, dir := range args.ExcludeDirs {
232+
args.Logger.Debug("EXCLUDED from watching", "dir", dir)
232233
excludeDirs[dir] = struct{}{}
233234
}
234235

0 commit comments

Comments
 (0)