The base problem is that:
1) assume there is a script that errors and exits quickly and is run with a spin time
2) while the script is being restarted a stop command arrives to the worker, if at this point the process has exited (and thus the kill call on the current pid will fail) no exit event will be emitted but the next restart queued by the spin timer will reset force close, thus the client waiting on stop will hang
This PR basically handles a pending restart timer in the stop call and also honours a pending force restart in the restart flow - since the start is queued by nextTick there is a small chance that a stop could still arrive after restartChild has just completed (thus no timer) but the process has not yet been started and thus again using the existing pid would fail.
Solves forever getting stuck on
stopall
andrestartall
as demonstrated by https://github.com/rubu/forever-stuck and described in https://github.com/foreversd/forever/issues/904.The base problem is that: 1) assume there is a script that errors and exits quickly and is run with a spin time 2) while the script is being restarted a stop command arrives to the worker, if at this point the process has exited (and thus the kill call on the current pid will fail) no exit event will be emitted but the next restart queued by the spin timer will reset force close, thus the client waiting on stop will hang
This PR basically handles a pending restart timer in the stop call and also honours a pending force restart in the restart flow - since the start is queued by nextTick there is a small chance that a stop could still arrive after restartChild has just completed (thus no timer) but the process has not yet been started and thus again using the existing pid would fail.