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
|
2016-03-30 21:25:42 +00:00
|
|
|
NoPivotRoot bool
|
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-03-30 21:25:42 +00:00
|
|
|
container, err := runtime.New(runtime.ContainerOpts{
|
|
|
|
Root: s.stateDir,
|
|
|
|
ID: t.ID,
|
|
|
|
Bundle: t.BundlePath,
|
|
|
|
Runtime: s.runtime,
|
|
|
|
RuntimeArgs: s.runtimeArgs,
|
2016-04-06 06:42:47 +00:00
|
|
|
Shim: s.shim,
|
2016-03-30 21:25:42 +00:00
|
|
|
Labels: t.Labels,
|
|
|
|
NoPivotRoot: t.NoPivotRoot,
|
2016-03-28 20:30:37 +00:00
|
|
|
Timeout: s.timeout,
|
2016-03-30 21:25:42 +00:00
|
|
|
})
|
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)
|
2016-04-02 17:28:05 +00:00
|
|
|
return errDeferredResponse
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|