2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-01 18:55:13 +00:00
|
|
|
|
2016-01-06 21:32:46 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/containerd/runtime"
|
|
|
|
)
|
2015-12-19 00:54:02 +00:00
|
|
|
|
2015-12-01 18:55:13 +00:00
|
|
|
type StartEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *StartEvent) Handle(e *Event) error {
|
2015-12-19 00:54:02 +00:00
|
|
|
start := time.Now()
|
2016-01-06 21:32:46 +00:00
|
|
|
container, err := runtime.New(h.s.stateDir, e.ID, e.BundlePath)
|
2015-12-01 18:55:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-12-11 19:27:33 +00:00
|
|
|
h.s.containers[e.ID] = &containerInfo{
|
|
|
|
container: container,
|
|
|
|
}
|
2015-12-01 18:55:13 +00:00
|
|
|
ContainersCounter.Inc(1)
|
2015-12-04 00:07:53 +00:00
|
|
|
task := &StartTask{
|
2015-12-16 00:22:53 +00:00
|
|
|
Err: e.Err,
|
|
|
|
Container: container,
|
|
|
|
StartResponse: e.StartResponse,
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
2015-12-04 00:07:53 +00:00
|
|
|
if e.Checkpoint != nil {
|
2015-12-04 22:00:07 +00:00
|
|
|
task.Checkpoint = e.Checkpoint.Name
|
2015-12-04 00:07:53 +00:00
|
|
|
}
|
|
|
|
h.s.tasks <- task
|
2015-12-19 00:54:02 +00:00
|
|
|
ContainerCreateTimer.UpdateSince(start)
|
2015-12-01 18:55:13 +00:00
|
|
|
return errDeferedResponse
|
|
|
|
}
|