func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
	if shuttingDown {
		http.Error(w, "Service shutting down", http.StatusServiceUnavailable)
	}
	io.WriteString(w, "Service OK")
}
HealthCheckHandler checks whether the instance is shutting down, and if so,
responds with 503 Service Unavailable.
package main
import (
	"context"
	"io"
	"net/http"
	"os"
	"os/signal"
	"time"
	"github.com/bradleyfalzon/gopherci/internal/logger"
)
var shuttingDown bool
func SignalHandler(logger logger.Logger, cancel context.CancelFunc, srv *http.Server) {
	c := make(chan os.Signal, 2)
	signal.Notify(c, os.Interrupt)
	var lastSignal time.Time
	for {
		s := <-c
		if time.Since(lastSignal) < time.Second {
			logger.Fatal("Two signals in short succession, forcing quit")
		}
		lastSignal = time.Now()
		logger.Infof("Received %v, preparing to shutdown", s)
		shuttingDown = true
		srv.Shutdown(context.Background())
		cancel()
	}
}