diff options
author | Valery Piashchynski <[email protected]> | 2021-12-15 00:12:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-12-15 00:12:23 +0300 |
commit | b4e4f7e7e60bff48a63df4a3c606398ea2a32d8a (patch) | |
tree | d018a39795b94f61e1dadde54ce3382fc7e039b0 /pool/static_pool.go | |
parent | f2c79017ae5759256b03ec58b608f298a29e4b96 (diff) |
Update static_pool and worker to wait response from the worker
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pool/static_pool.go')
-rwxr-xr-x | pool/static_pool.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pool/static_pool.go b/pool/static_pool.go index 9897b9e7..9636f19f 100755 --- a/pool/static_pool.go +++ b/pool/static_pool.go @@ -319,7 +319,7 @@ func (sp *StaticPool) execDebug(p *payload.Payload) (*payload.Payload, error) { // destroy the worker sw.State().Set(worker.StateDestroyed) - err = sw.Kill() + err = sw.Stop() if err != nil { sp.events.Send(events.NewEvent(events.EventWorkerError, pluginName, fmt.Sprintf("error: %s, worker's pid: %d", err, sw.Pid()))) return nil, err @@ -337,6 +337,16 @@ func (sp *StaticPool) execDebugWithTTL(ctx context.Context, p *payload.Payload) // redirect call to the worker with TTL r, err := sw.ExecWithTTL(ctx, p) + if err != nil { + return nil, err + } + + go func() { + // read the exit status to prevent process to be a zombie + _ = sw.Wait() + }() + + sw.State().Set(worker.StateDestroyed) if stopErr := sw.Stop(); stopErr != nil { sp.events.Send(events.NewEvent(events.EventWorkerError, pluginName, fmt.Sprintf("error: %s, pid: %d", err, sw.Pid()))) } |