containerd/supervisor/add_process.go
Michael Crosby 36eb83cb99 Move fifo creation to client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-03 13:56:15 -08:00

35 lines
737 B
Go

package supervisor
import (
"time"
"github.com/docker/containerd/runtime"
)
type AddProcessEvent struct {
s *Supervisor
}
// TODO: add this to worker for concurrent starts??? maybe not because of races where the container
// could be stopped and removed...
func (h *AddProcessEvent) Handle(e *Event) error {
start := time.Now()
ci, ok := h.s.containers[e.ID]
if !ok {
return ErrContainerNotFound
}
process, err := ci.container.Exec(e.Pid, *e.ProcessSpec, runtime.Stdio{
Stdin: e.Stdin,
Stdout: e.Stdout,
Stderr: e.Stderr,
})
if err != nil {
return err
}
if err := h.s.monitorProcess(process); err != nil {
return err
}
ExecProcessTimer.UpdateSince(start)
e.StartResponse <- StartResponse{}
return nil
}