diff options
author | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 15:12:54 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 15:12:54 +0200 |
commit | eb2e58baeb7984b34e77efcb3a1b499eff186ad4 (patch) | |
tree | fd5d3c8b5e3ae000a3cc95273be5ea771b59ae25 | |
parent | 671f8e0fbbcb7194d5f59a6927f7752e86f6282c (diff) |
Move warning print
-rw-r--r-- | main.go | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -86,9 +86,6 @@ func main() { log.Printf("INFO: starting work generator\n") workGenerator(ctx, opts, fp, questionCh) - if err := ctx.Err(); err != nil { - log.Printf("WARNING: premature shutdown (context cancelled)\n") - } } func await(ctx context.Context, cancel context.CancelFunc) { @@ -98,10 +95,10 @@ func await(ctx context.Context, cancel context.CancelFunc) { signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) select { case <-sigs: + log.Printf("WARNING: premature shutdown (context cancelled)\n") + cancel() case <-ctx.Done(): } - - cancel() } func work(ctx context.Context, cli *http.Client, timeout time.Duration, question qna.Question, answerCh chan qna.Answer) { |