73f77f1624
This makes systemd not put unit into fail mode when stopping INFO: * make sure to use signals.RegisterCloser for everything that should be closed on interrupt * for any net.Listeners created make sure to wrap them with network.WrapListener and register with signals.RegisterCloser
17 lignes
290 o
Go
17 lignes
290 o
Go
package network
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
)
|
|
|
|
// implements io.Closer that gracefully closes an http server
|
|
type GracefulHttpCloser struct {
|
|
Server *http.Server
|
|
Listener net.Listener
|
|
}
|
|
|
|
func (c *GracefulHttpCloser) Close() error {
|
|
c.Listener.Close()
|
|
return c.Server.Shutdown(nil)
|
|
}
|