dmitri.shuralyov.com/website/gido/...

refactor interrupt signal handling

Use the same simpler style as in other projects.
dmitshur committed 5 years ago commit c6d3558e07d8cef32ca2d24d23705aeb704a075c
Collapse all
main.go
@@ -44,17 +44,14 @@ func main() {
		fmt.Fprintf(os.Stderr, "invalid -router flag value %q\n", *routerFlag)
		flag.Usage()
		os.Exit(2)
	}

	int := make(chan os.Signal, 1)
	signal.Notify(int, os.Interrupt)
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		sigint := make(chan os.Signal, 1)
		signal.Notify(sigint, os.Interrupt)
		<-sigint
		cancel()
	}()
	go func() { <-int; cancel() }()

	err := run(ctx, router, *analyticsFileFlag)
	if err != nil {
		log.Fatalln(err)
	}