Skip to content

Commit

Permalink
More graceful exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
bakks committed Oct 27, 2022
1 parent c546a55 commit 8f5731f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -507,7 +508,8 @@ func periodic(ctx context.Context, interval time.Duration, fn func() error) {
for {
select {
case <-ticker.C:
if err := fn(); err != nil {
err := fn()
if err != nil && !errors.Is(err, context.Canceled) {
panic(err)
}
case <-ctx.Done():
Expand Down

0 comments on commit 8f5731f

Please sign in to comment.