Skip to content
Permalink
Browse files

Ping the service manager early

Maybe
fixes #548

(untested)
  • Loading branch information...
jedisct1 committed Jul 19, 2018
1 parent daa10c9 commit c043bd73dd6ac8737b07e42763a4a3c37ce8187b
@@ -45,7 +45,7 @@ func main() {
dlog.Debug(err)
}
app.proxy = NewProxy()

_ = ServiceManagerStartNotify()
if err := ConfigLoad(&app.proxy, svcFlag); err != nil {
dlog.Fatal(err)
}
@@ -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")
@@ -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)
@@ -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")
}
@@ -0,0 +1,10 @@
// +build !linux,!windows

package main

func ServiceManagerStartNotify() error {
return nil
}

func ServiceManagerReadyNotify() {
}
@@ -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() {}
@@ -5,5 +5,3 @@ package main
func (proxy *Proxy) SystemDListeners() error {
return nil
}

func SystemDNotify() {}
@@ -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")
}

0 comments on commit c043bd7

Please sign in to comment.
You can’t perform that action at this time.