MCPcopy Create free account
hub / github.com/screego/server / shutdownOnInterruptSignal

Function shutdownOnInterruptSignal

server/server.go:66–79  ·  view source on GitHub ↗
(server *http.Server, timeout time.Duration, shutdown chan<- error)

Source from the content-addressed store, hash-verified

64}
65
66func shutdownOnInterruptSignal(server *http.Server, timeout time.Duration, shutdown chan<- error) {
67 interrupt := make(chan os.Signal, 1)
68 notifySignal(interrupt, os.Interrupt)
69
70 go func() {
71 <-interrupt
72 log.Info().Msg("Received interrupt. Shutting down...")
73 ctx, cancel := context.WithTimeout(context.Background(), timeout)
74 defer cancel()
75 if err := serverShutdown(server, ctx); err != nil {
76 shutdown <- err
77 }
78 }()
79}
80
81func waitForServerToClose(shutdown <-chan error) error {
82 err := <-shutdown

Callers 1

StartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected