Skip to content

Commit cc1aac7

Browse files
committed
force immediate snapshot by sending SIGUSR2
1 parent c369cec commit cc1aac7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ func lastGoodTicker(in, out chan *snapshot, cl clock) {
5454
debugf("gap: %s", gap)
5555
wait = schedules[config.Schedule][0] - gap
5656
if wait > 0 {
57+
sigc := make(chan os.Signal, 1)
58+
signal.Notify(sigc, syscall.SIGUSR2)
5759
log.Println("wait", wait, "before next snapshot")
58-
time.Sleep(wait)
59-
debugf("Awoken at %s\n", cl.Now())
60+
select {
61+
case <-sigc:
62+
log.Println("Snapshot forced by signal, skipping wait time.")
63+
case <-time.After(wait):
64+
debugf("Awoken at %s\n", cl.Now())
65+
}
6066
}
6167
}
6268
out <- sn

0 commit comments

Comments
 (0)