diff --git a/supervisor/container.go b/supervisor/container.go index 5dae98d6..319729ff 100644 --- a/supervisor/container.go +++ b/supervisor/container.go @@ -29,7 +29,9 @@ type Container struct { ownerPod *HyperPod } -func (c *Container) run(p *Process) { +func (c *Container) run(p *Process) error { + resultCh := make(chan error) + go func() { err := c.create(p) if err != nil { @@ -51,6 +53,9 @@ func (c *Container) run(p *Process) { } c.ownerPod.sv.Events.notifySubscribers(e) + resultCh <- err + close(resultCh) + exit, err := c.wait(p, res) e = Event{ ID: c.Id, @@ -65,6 +70,9 @@ func (c *Container) run(p *Process) { } c.ownerPod.sv.Events.notifySubscribers(e) }() + + err := <-resultCh + return err } func (c *Container) create(p *Process) error { diff --git a/supervisor/hyperpod.go b/supervisor/hyperpod.go index b1bd03d3..7a00621f 100644 --- a/supervisor/hyperpod.go +++ b/supervisor/hyperpod.go @@ -416,7 +416,9 @@ func (hp *HyperPod) createContainer(container, bundlePath, stdin, stdout, stderr c.ownerPod.Containers[container] = c glog.Infof("createContainer() calls c.run(p)") - c.run(p) + if err := c.run(p); err != nil { + return nil, err + } return c, nil }