Ping the service manager early

Maybe
fixes #548

(untested)
This commit is contained in:
Frank Denis 2018-07-19 19:03:57 +02:00
parent daa10c92af
commit c043bd73dd
8 changed files with 39 additions and 10 deletions

View File

@ -45,7 +45,7 @@ func main() {
dlog.Debug(err)
}
app.proxy = NewProxy()
_ = ServiceManagerStartNotify()
if err := ConfigLoad(&app.proxy, svcFlag); err != nil {
dlog.Fatal(err)
}

View File

@ -38,7 +38,7 @@ func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
dlog.Fatal(err)
}
SystemDNotify()
ServiceManagerReadyNotify()
args = args[1:]
args = append(args, "-child")

View File

@ -154,7 +154,7 @@ func (proxy *Proxy) StartProxy() {
if liveServers > 0 {
dlog.Noticef("dnscrypt-proxy is ready - live servers: %d", liveServers)
if !proxy.child {
SystemDNotify()
ServiceManagerReadyNotify()
}
} else if err != nil {
dlog.Error(err)

View File

@ -0,0 +1,12 @@
package main
import "github.com/coreos/go-systemd/daemon"
func ServiceManagerStartNotify() error {
daemon.SdNotify(false, "STATUS=Starting")
return nil
}
func ServiceManagerReadyNotify() {
daemon.SdNotify(false, "READY=1")
}

View File

@ -0,0 +1,10 @@
// +build !linux,!windows
package main
func ServiceManagerStartNotify() error {
return nil
}
func ServiceManagerReadyNotify() {
}

View File

@ -0,0 +1,14 @@
package main
import "golang.org/x/sys/windows/svc/mgr"
func ServiceManagerStartNotify() error {
mgr, err := mgr.Connect()
if err != nil {
return err
}
mgr.Disconnect()
return nil
}
func ServiceManagerReadyNotify() {}

View File

@ -5,5 +5,3 @@ package main
func (proxy *Proxy) SystemDListeners() error {
return nil
}
func SystemDNotify() {}

View File

@ -4,7 +4,6 @@ import (
"net"
"github.com/coreos/go-systemd/activation"
"github.com/coreos/go-systemd/daemon"
"github.com/jedisct1/dlog"
)
@ -28,7 +27,3 @@ func (proxy *Proxy) SystemDListeners() error {
return nil
}
func SystemDNotify() {
daemon.SdNotify(false, "READY=1")
}