containerd/add_process.go
Michael Crosby 3010f209ff Refactor container info in supervisor
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-12-11 11:27:33 -08:00

36 lines
835 B
Go

package containerd
import "github.com/Sirupsen/logrus"
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 {
ci, ok := h.s.containers[e.ID]
if !ok {
return ErrContainerNotFound
}
p, io, err := h.s.runtime.StartProcess(ci.container, *e.Process)
if err != nil {
return err
}
l, err := h.s.log(ci.container.Path(), io)
if err != nil {
// log the error but continue with the other commands
logrus.WithFields(logrus.Fields{
"error": err,
"id": e.ID,
}).Error("log stdio")
}
if e.Pid, err = p.Pid(); err != nil {
return err
}
h.s.processes[e.Pid] = &containerInfo{
container: ci.container,
logger: l,
}
return nil
}