execution: properly monitor restored processes

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-01-12 10:31:42 -08:00
parent 3cb57fa2d6
commit 37a113f9fb

View file

@ -31,11 +31,11 @@ func New(ctx context.Context, executor Executor) (*Service, error) {
for _, c := range containers { for _, c := range containers {
status := c.Status() status := c.Status()
if status == Stopped || status == Deleted { // generate exit event for all processes, (generate event for init last)
// generate exit event for all processes, (generate event for init last) processes := c.Processes()
processes := c.Processes() processes = append(processes[1:], processes[0])
processes = append(processes[1:], processes[0]) for _, p := range c.processes {
for _, p := range processes { if status == Stopped || status == Deleted {
if p.Status() != Stopped { if p.Status() != Stopped {
p.Signal(os.Kill) p.Signal(os.Kill)
} }
@ -53,6 +53,8 @@ func New(ctx context.Context, executor Executor) (*Service, error) {
PID: p.ID(), PID: p.ID(),
StatusCode: sc, StatusCode: sc,
}) })
} else {
svc.monitorProcess(ctx, c, p)
} }
} }
} }
@ -156,7 +158,6 @@ func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest)
return nil, err return nil, err
} }
// TODO: generate spec
spec := specs.Process{ spec := specs.Process{
Terminal: r.Process.Terminal, Terminal: r.Process.Terminal,
ConsoleSize: specs.Box{ ConsoleSize: specs.Box{