From 1c931821c1fcd47c904e85850c1b4c811148c28f Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 24 May 2018 09:55:40 +0100 Subject: [PATCH] Really notify systemd, don't just say we do Doh, don't know how this was missed until now. --- serverutil/http.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/serverutil/http.go b/serverutil/http.go index 7fbd69f..3232949 100644 --- a/serverutil/http.go +++ b/serverutil/http.go @@ -13,6 +13,7 @@ import ( "syscall" "time" + "github.com/coreos/go-systemd/daemon" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -82,7 +83,8 @@ func Serve(h http.Handler, config *ServerConfig, addr string) error { return err } - // Create the net.Listener, then notify systemd that we are ready to serve. + // Create the net.Listener first, so we can detect + // initialization-time errors safely. l, err := net.Listen("tcp", addr) if err != nil { return err @@ -113,6 +115,9 @@ func Serve(h http.Handler, config *ServerConfig, addr string) error { signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) + // Notify systemd that we are ready to serve. + daemon.SdNotify(false, "READY=1") + err = srv.Serve(l) if err != http.ErrServerClosed { return err -- GitLab