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
|
|
|
|
2016-02-12 01:26:24 +00:00
|
|
|
type StartTask struct {
|
2016-02-17 18:55:54 +00:00
|
|
|
baseTask
|
2016-02-26 03:18:10 +00:00
|
|
|
platformStartTask
|
2016-02-17 18:55:54 +00:00
|
|
|
ID string
|
|
|
|
BundlePath string
|
|
|
|
Stdout string
|
|
|
|
Stderr string
|
|
|
|
Stdin string
|
|
|
|
StartResponse chan StartResponse
|
|
|
|
Labels []string
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
func (s *Supervisor) start(t *StartTask) error {
|
2015-12-19 00:54:02 +00:00
|
|
|
start := time.Now()
|
2016-02-17 18:55:54 +00:00
|
|
|
container, err := runtime.New(s.stateDir, t.ID, t.BundlePath, t.Labels)
|
2015-12-01 18:55:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-02-17 18:55:54 +00:00
|
|
|
s.containers[t.ID] = &containerInfo{
|
2015-12-11 19:27:33 +00:00
|
|
|
container: container,
|
|
|
|
}
|
2015-12-01 18:55:13 +00:00
|
|
|
ContainersCounter.Inc(1)
|
2016-02-12 01:26:24 +00:00
|
|
|
task := &startTask{
|
2016-02-17 18:55:54 +00:00
|
|
|
Err: t.ErrorCh(),
|
2015-12-16 00:22:53 +00:00
|
|
|
Container: container,
|
2016-02-17 18:55:54 +00:00
|
|
|
StartResponse: t.StartResponse,
|
|
|
|
Stdin: t.Stdin,
|
|
|
|
Stdout: t.Stdout,
|
|
|
|
Stderr: t.Stderr,
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
2016-02-26 03:18:10 +00:00
|
|
|
task.setTaskCheckpoint(t)
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
s.startTasks <- task
|
2015-12-19 00:54:02 +00:00
|
|
|
ContainerCreateTimer.UpdateSince(start)
|
2015-12-01 18:55:13 +00:00
|
|
|
return errDeferedResponse
|
|
|
|
}
|