exit with err if cancelled and newline
This commit is contained in:
11
main.go
11
main.go
@@ -34,9 +34,19 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for alert := range alerts {
|
for alert := range alerts {
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
if err := alertAt(ctx, *ntfy, time.Now(), alert, time.Now().Format("15:04")); err != nil && ctx.Err() == nil {
|
if err := alertAt(ctx, *ntfy, time.Now(), alert, time.Now().Format("15:04")); err != nil && ctx.Err() == nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ctx.Err(); err != nil {
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +74,7 @@ func alertsAfter(ctx context.Context, dur time.Duration) (chan string, error) {
|
|||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Println()
|
||||||
ch <- "alerting after " + dur.String()
|
ch <- "alerting after " + dur.String()
|
||||||
}()
|
}()
|
||||||
return ch, nil
|
return ch, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user