Don't you want `waitSeconds` to reset to 1 at some point?  Exponential back-off makes sense to prevent rapid restart attempts; but for a long-running command that fails infrequently and then successfully restarts soon thereafter, you probably don't want the restart attempts after the next failure (hours or days away) to only be attempted after longer and longer delays.