summaryrefslogtreecommitdiff
path: root/pkg/worker/worker.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-23 23:35:44 +0300
committerValery Piashchynski <[email protected]>2020-12-23 23:35:44 +0300
commite78c13d93a729a9008f283aa3db6910f3e833165 (patch)
treee633604841b80c42b195388429dc12349e4b9d1f /pkg/worker/worker.go
parentc21fe8e2f99c3cb8e3c1482e35f2efa0e914c337 (diff)
Initial implementation of serve, reset, workers commands for the RR2
Diffstat (limited to 'pkg/worker/worker.go')
-rwxr-xr-xpkg/worker/worker.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go
index 6e9141c9..db182a3e 100755
--- a/pkg/worker/worker.go
+++ b/pkg/worker/worker.go
@@ -191,6 +191,10 @@ func (w *Process) Wait() error {
const op = errors.Op("worker process wait")
err := multierr.Combine(w.cmd.Wait())
+ if w.State().Value() == internal.StateDestroyed {
+ return errors.E(op, err)
+ }
+
// at this point according to the documentation (see cmd.Wait comment)
// if worker finishes with an error, message will be written to the stderr first
// and then w.cmd.Wait return an error
@@ -249,6 +253,14 @@ func (w *Process) Stop() error {
// Kill kills underlying process, make sure to call Wait() func to gather
// error log from the stderr. Does not waits for process completion!
func (w *Process) Kill() error {
+ if w.State().Value() == internal.StateDestroyed {
+ err := w.cmd.Process.Signal(os.Kill)
+ if err != nil {
+ return err
+ }
+ return nil
+ }
+
w.state.Set(internal.StateKilling)
err := w.cmd.Process.Signal(os.Kill)
if err != nil {