Skip to content

Commit

Permalink
feat: add ctrl+c handler
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Oct 20, 2024
1 parent a228487 commit 8e9fb39
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/fast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package main
import (
"flag"
"log"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/adhocore/chin"
Expand All @@ -23,9 +26,17 @@ func main() {
s := chin.New().WithWait(&wg)
go s.Start()

var sig = make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGABRT)

wg.Add(1)
go doFast(s, &wg, noUp)

go func() {
<-sig
s.Stop()
}()

wg.Wait()
}

Expand Down

0 comments on commit 8e9fb39

Please sign in to comment.