diff options
author | Wolfy-J <[email protected]> | 2018-06-05 23:17:14 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-05 23:17:14 +0300 |
commit | e594c7070aad609c4caeda760671aca00e638561 (patch) | |
tree | b7ecb76ceeba88e03635c238a67f237452c20524 /worker.go | |
parent | 6adaf713b47c9a3ab3a516e21d2d4ecf7f2075d6 (diff) |
fixing controlled descruction
Diffstat (limited to 'worker.go')
-rw-r--r-- | worker.go | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -114,7 +114,7 @@ func (w *Worker) Wait() error { return nil } - if w.state.Value() != StateDestructing { + if w.state.Value() != StateStopping { w.state.set(StateErrored) } else { w.state.set(StateStopped) @@ -130,17 +130,6 @@ func (w *Worker) Wait() error { // Stop sends soft termination command to the worker and waits for process completion. func (w *Worker) Stop() error { - return w.doStop(StateStopping) -} - -// Destroy is identical to stop command but does mark workers with different state. Destroyed workers won't -// throw error state on completion of process destruction (exit status). -func (w *Worker) Destroy() error { - return w.doStop(StateDestructing) -} - -// actual stopping. -func (w *Worker) doStop(state int64) error { select { case <-w.waitDone: return nil @@ -148,7 +137,7 @@ func (w *Worker) doStop(state int64) error { w.mu.Lock() defer w.mu.Unlock() - w.state.set(state) + w.state.set(StateStopping) err := sendPayload(w.rl, &stopCommand{Stop: true}) <-w.waitDone @@ -163,7 +152,7 @@ func (w *Worker) Kill() error { case <-w.waitDone: return nil default: - w.state.set(StateDestructing) + w.state.set(StateStopping) err := w.cmd.Process.Signal(os.Kill) <-w.waitDone |