diff options
author | Valery Piashchynski <[email protected]> | 2020-12-21 10:27:10 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-21 10:27:10 +0300 |
commit | 2f71f79ac704ed95dad961677b6e602e38641b5d (patch) | |
tree | 7452bbedd1444079757a848ad07089bc6093561f /pkg/worker/worker.go | |
parent | 3d4c75aadd9ffd0d46728f48f685de2e1bfc44bb (diff) |
Remove unused contex from interfaces. Update pool allocator.
Diffstat (limited to 'pkg/worker/worker.go')
-rwxr-xr-x | pkg/worker/worker.go | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go index e60ab3f4..456f4bea 100755 --- a/pkg/worker/worker.go +++ b/pkg/worker/worker.go @@ -2,7 +2,6 @@ package worker import ( "bytes" - "context" "fmt" "io" "os" @@ -220,30 +219,16 @@ func (w *Process) closeRelay() error { } // Stop sends soft termination command to the Process and waits for process completion. -func (w *Process) Stop(ctx context.Context) error { - c := make(chan error) - - go func() { - var err error - w.state.Set(internal.StateStopping) - err = multierr.Append(err, internal.SendControl(w.relay, &internal.StopCommand{Stop: true})) - if err != nil { - w.state.Set(internal.StateKilling) - c <- multierr.Append(err, w.cmd.Process.Kill()) - } - w.state.Set(internal.StateStopped) - c <- nil - }() - - select { - case <-ctx.Done(): - return ctx.Err() - case err := <-c: - if err != nil { - return err - } - return nil +func (w *Process) Stop() error { + var err error + w.state.Set(internal.StateStopping) + err = multierr.Append(err, internal.SendControl(w.relay, &internal.StopCommand{Stop: true})) + if err != nil { + w.state.Set(internal.StateKilling) + return multierr.Append(err, w.cmd.Process.Kill()) } + w.state.Set(internal.StateStopped) + return nil } // Kill kills underlying process, make sure to call Wait() func to gather |