func shutdownListener() context.Context {
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		interruptChannel := make(chan os.Signal, 1)
		signal.Notify(interruptChannel, interruptSignals...)
		select {
		case sig := <-interruptChannel:
			log.Infof("Received signal (%s).  Shutting down...", sig)
		case <-shutdownRequestChannel:
			log.Infof("Shutdown requested.  Shutting down...")
		}
		cancel()
		for {
			select {
			case sig := <-interruptChannel:
				log.Infof("Received signal (%s).  Already "+
					"shutting down...", sig)
			case <-shutdownRequestChannel:
				log.Info("Shutdown requested.  Already " +
					"shutting down...")
			}
		}
	}()
	return ctx
}
shutdownListener listens for OS Signals such as SIGINT (Ctrl+C) and shutdown
requests from shutdownRequestChannel.  It returns a context that is canceled
when either signal is received.
package main
import (
	"context"
	"os"
	"os/signal"
)
var shutdownRequestChannel = make(chan struct{})
var interruptSignals = []os.Signal{os.Interrupt}
func requestShutdown() {
	shutdownRequestChannel <- struct{}{}
}