Skip to content

Conversation

@rubu
Copy link

@rubu rubu commented Jul 11, 2024

Solves forever getting stuck on stopall and restartall as demonstrated by https://github.com/rubu/forever-stuck and described in foreversd/forever#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant