diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,8 +1,12 @@ package main import ( + "context" "flag" "log" + "os" + "os/signal" + "syscall" ) var ( @@ -31,7 +35,10 @@ func main() { log.Fatalf("initial sync failed: %v", err) } - if err := watch(*hostDir, *dataDir, manifest, rules, *dryRun, *verbose); err != nil { + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer cancel() + + if err := watch(ctx, *hostDir, *dataDir, manifest, rules, *dryRun, *verbose); err != nil { log.Fatalf("watcher failed: %v", err) } } |
