提交 d7f9b8cb 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!60 build: wait all builder goroutines when stop daemon

Merge pull request !60 from zvier/bep
......@@ -26,6 +26,7 @@ type Backend struct {
sync.RWMutex
daemon *Daemon
status map[string]*status
wg sync.WaitGroup
}
// NewBackend create an instance of backend
......@@ -33,6 +34,7 @@ func (d *Daemon) NewBackend() {
d.backend = &Backend{
daemon: d,
status: make(map[string]*status),
wg: sync.WaitGroup{},
}
}
......
......@@ -31,6 +31,8 @@ import (
// Build receives a build request and build an image
func (b *Backend) Build(req *pb.BuildRequest, stream pb.Control_BuildServer) (err error) { // nolint:gocyclo
b.wg.Add(1)
defer b.wg.Done()
logrus.WithFields(logrus.Fields{
"BuildType": req.GetBuildType(),
"BuildID": req.GetBuildID(),
......
......@@ -126,6 +126,7 @@ func (d *Daemon) Run() error {
systemd.NotifySystemStopping()
d.grpc.server.GracefulStop()
d.backend.wg.Wait()
return err
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册