Skip to content

Commit

Permalink
Merge pull request #984 from AkihiroSuda/sd-notify
Browse files Browse the repository at this point in the history
buildkitd: support sd_notify
  • Loading branch information
tonistiigi committed May 9, 2019
2 parents 95660b2 + 0dee033 commit 646fc0a
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 3 deletions.
10 changes: 10 additions & 0 deletions cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/containerd/containerd/pkg/seed"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/sys"
sddaemon "github.com/coreos/go-systemd/daemon"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/go-connections/sockets"
"github.com/gofrs/flock"
Expand Down Expand Up @@ -267,6 +268,10 @@ func main() {
}

logrus.Infof("stopping server")
if os.Getenv("NOTIFY_SOCKET") != "" {
notified, notifyErr := sddaemon.SdNotify(false, sddaemon.SdNotifyStopping)
logrus.Debugf("SdNotifyStopping notified=%v, err=%v", notified, notifyErr)
}
server.GracefulStop()

return err
Expand Down Expand Up @@ -304,6 +309,11 @@ func serveGRPC(cfg config.GRPCConfig, server *grpc.Server, errCh chan error) err
}
listeners = append(listeners, l)
}

if os.Getenv("NOTIFY_SOCKET") != "" {
notified, notifyErr := sddaemon.SdNotify(false, sddaemon.SdNotifyReady)
logrus.Debugf("SdNotifyReady notified=%v, err=%v", notified, notifyErr)
}
for _, l := range listeners {
func(l net.Listener) {
eg.Go(func() error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 // indirect
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd // indirect
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/docker/cli v0.0.0-20190321234815-f40f9c240ab0
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 h1:SKDlsIhYxNE1LO
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8NEo3bC/vx9pbi/g2WI8mtP2/nXzu297Y=
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b h1:+mtZ0WjVZwTX0RVrXMXDwuYVaNeHGvWBW1UwJeMR+2M=
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
191 changes: 191 additions & 0 deletions vendor/github.com/coreos/go-systemd/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/coreos/go-systemd/NOTICE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions vendor/github.com/coreos/go-systemd/daemon/sdnotify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 646fc0a

Please sign in to comment.