forked from projecteru2/agent
/
load.go
35 lines (30 loc) · 836 Bytes
/
load.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package engine
import (
log "github.com/Sirupsen/logrus"
"github.com/projecteru2/agent/common"
)
func (e *Engine) load() error {
log.Info("[load] Load containers")
containers, err := e.listContainers(true, nil)
if err != nil {
return err
}
for _, container := range containers {
log.Debugf("[load] detect container %s", container.ID[:common.SHORTID])
c, err := e.detectContainer(container.ID, container.Labels)
if err != nil {
log.Errorf("[load] detect container failed %v", err)
continue
}
if c.Running {
//TODO 这里应该用文档说明你丫的远端得有东西
//if _, ok := container.Labels["agent"]; !ok || !e.dockerized {
e.attach(c)
//}
}
if err := e.store.DeployContainer(c, e.node); err != nil {
log.Errorf("[load] update deploy status failed %v", err)
}
}
return nil
}