Skip to content

Commit

Permalink
Watch wrapper process (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
tebeka authored and omesser committed Nov 21, 2019
1 parent 57fceb9 commit 70efb54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/processor/runtime/python/runtime.go
Expand Up @@ -97,7 +97,7 @@ func (py *python) RunWrapper(socketPath string) (*os.Process, error) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Env = env
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
cmd.Stderr = os.Stderr

return cmd.Process, cmd.Start()
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/processor/runtime/rpc/abstract.go
Expand Up @@ -225,6 +225,7 @@ func (r *AbstractRuntime) startWrapper() error {
return errors.Wrap(err, "Can't run wrapper")
}
r.wrapperProcess = wrapperProcess
go r.watchWrapperProcess()

conn, err := listener.Accept()
if err != nil {
Expand Down Expand Up @@ -413,3 +414,13 @@ func (r *AbstractRuntime) newResultChan() {
// We create the channel buffered so we won't block on sending
r.resultChan = make(chan *result, 1)
}

func (r *AbstractRuntime) watchWrapperProcess() {
procStatus, err := r.wrapperProcess.Wait()
if r.GetStatus() == status.Ready && (err != nil || !procStatus.Success()) {
r.Logger.ErrorWith("Unexpected termination of child process", "error", err, "status", procStatus.String())
}
r.SetStatus(status.Stopped)
r.wrapperProcess = nil
// TODO: Do we want to exit the processor here?
}

0 comments on commit 70efb54

Please sign in to comment.