containerd/supervisor/add_process.go
Michael Crosby 4e05bf491a Remove eventloop package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-19 13:21:21 -08:00

43 lines
903 B
Go

package supervisor
import (
"time"
"github.com/docker/containerd/runtime"
"github.com/opencontainers/specs"
)
type AddProcessTask struct {
baseTask
ID string
PID string
Stdout string
Stderr string
Stdin string
ProcessSpec *specs.Process
StartResponse chan StartResponse
}
func (s *Supervisor) addProcess(t *AddProcessTask) error {
start := time.Now()
ci, ok := s.containers[t.ID]
if !ok {
return ErrContainerNotFound
}
process, err := ci.container.Exec(t.PID, *t.ProcessSpec, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr))
if err != nil {
return err
}
if err := s.monitorProcess(process); err != nil {
return err
}
ExecProcessTimer.UpdateSince(start)
t.StartResponse <- StartResponse{}
s.notifySubscribers(Event{
Timestamp: time.Now(),
Type: "start-process",
PID: t.PID,
ID: t.ID,
})
return nil
}