Skip to content

Commit 646fc0a

Browse files
authored
Merge pull request #984 from AkihiroSuda/sd-notify
buildkitd: support sd_notify
2 parents 95660b2 + 0dee033 commit 646fc0a

File tree

8 files changed

+368
-3
lines changed

8 files changed

+368
-3
lines changed

cmd/buildkitd/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/containerd/containerd/pkg/seed"
2020
"github.com/containerd/containerd/platforms"
2121
"github.com/containerd/containerd/sys"
22+
sddaemon "github.com/coreos/go-systemd/daemon"
2223
"github.com/docker/docker/pkg/reexec"
2324
"github.com/docker/go-connections/sockets"
2425
"github.com/gofrs/flock"
@@ -267,6 +268,10 @@ func main() {
267268
}
268269

269270
logrus.Infof("stopping server")
271+
if os.Getenv("NOTIFY_SOCKET") != "" {
272+
notified, notifyErr := sddaemon.SdNotify(false, sddaemon.SdNotifyStopping)
273+
logrus.Debugf("SdNotifyStopping notified=%v, err=%v", notified, notifyErr)
274+
}
270275
server.GracefulStop()
271276

272277
return err
@@ -304,6 +309,11 @@ func serveGRPC(cfg config.GRPCConfig, server *grpc.Server, errCh chan error) err
304309
}
305310
listeners = append(listeners, l)
306311
}
312+
313+
if os.Getenv("NOTIFY_SOCKET") != "" {
314+
notified, notifyErr := sddaemon.SdNotify(false, sddaemon.SdNotifyReady)
315+
logrus.Debugf("SdNotifyReady notified=%v, err=%v", notified, notifyErr)
316+
}
307317
for _, l := range listeners {
308318
func(l net.Listener) {
309319
eg.Go(func() error {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3
1616
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 // indirect
1717
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd // indirect
18-
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b // indirect
18+
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
1919
github.com/docker/cli v0.0.0-20190321234815-f40f9c240ab0
2020
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
2121
github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 h1:SKDlsIhYxNE1LO
2828
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
2929
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8NEo3bC/vx9pbi/g2WI8mtP2/nXzu297Y=
3030
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
31-
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b h1:+mtZ0WjVZwTX0RVrXMXDwuYVaNeHGvWBW1UwJeMR+2M=
32-
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
31+
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
32+
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
3333
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
3434
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3535
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

vendor/github.com/coreos/go-systemd/LICENSE

Lines changed: 191 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/NOTICE

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/daemon/sdnotify.go

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)