func setupSignalHandler()

in main.go [133:149]


func setupSignalHandler() (context.Context, <-chan struct{}) {
	close(onlyOneSignalHandler) // panics when called twice

	ctx, cancel := context.WithCancel(context.Background())
	stop := make(chan struct{})
	c := make(chan os.Signal, 2)
	signal.Notify(c, shutdownSignals...)
	go func() {
		<-c
		cancel()
		close(stop)
		<-c
		os.Exit(1) // second signal. Exit directly.
	}()

	return ctx, stop
}