Skip to content

Commit

Permalink
force immediate snapshot by sending SIGUSR2
Browse files Browse the repository at this point in the history
  • Loading branch information
sstark committed Oct 27, 2018
1 parent c369cec commit cc1aac7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ func lastGoodTicker(in, out chan *snapshot, cl clock) {
debugf("gap: %s", gap)
wait = schedules[config.Schedule][0] - gap
if wait > 0 {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGUSR2)
log.Println("wait", wait, "before next snapshot")
time.Sleep(wait)
debugf("Awoken at %s\n", cl.Now())
select {
case <-sigc:
log.Println("Snapshot forced by signal, skipping wait time.")
case <-time.After(wait):
debugf("Awoken at %s\n", cl.Now())
}
}
}
out <- sn
Expand Down

0 comments on commit cc1aac7

Please sign in to comment.