INNER CODE UNIT · Go
sig
nicholasjackson/fake-service · main.go:316
sig := <-c
log.Println("Graceful shutdown, got signal:", sig)
// if the server does not gracefully stop after 30s, kill it
timer := time.AfterFunc(30*time.Second, func() {
grpcServer.Stop() // force stop the server
})
grpcServer.GracefulStop()
timer.Stop()
// gracefully shutdown the HTTP server, waiting max 30 seconds for current operations to complete
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
httpServer.Shutdown(ctx)
m.Close()
}