Skip to content

Commit

Permalink
Add maxbackoff and backoffincrement options
Browse files Browse the repository at this point in the history
* maxbackoff - the maximum number of seconds that supervisor will
  backoff before restart

* backoffincrement - the number of seconds to add to the backoff after
  each retry
  • Loading branch information
cdelguercio committed Feb 28, 2024
1 parent 4c845a3 commit 40a9af2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions supervisor/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,8 @@ def get(section, opt, *args, **kwargs):
autorestart = auto_restart(get(section, 'autorestart', 'unexpected'))
startsecs = integer(get(section, 'startsecs', 1))
startretries = integer(get(section, 'startretries', 3))
maxbackoff = integer(get(section, 'maxbackoff', 0))
backoffincrement = integer(get(section, 'backoffincrement', 1))
stopsignal = signal_number(get(section, 'stopsignal', 'TERM'))
stopwaitsecs = integer(get(section, 'stopwaitsecs', 10))
stopasgroup = boolean(get(section, 'stopasgroup', 'false'))
Expand Down Expand Up @@ -1870,6 +1872,7 @@ class ProcessConfig(Config):
req_param_names = [
'name', 'uid', 'command', 'directory', 'umask', 'priority',
'autostart', 'autorestart', 'startsecs', 'startretries',
'maxbackoff', 'backoffincrement,'
'stdout_logfile', 'stdout_capture_maxbytes',
'stdout_events_enabled', 'stdout_syslog',
'stdout_logfile_backups', 'stdout_logfile_maxbytes',
Expand Down
3 changes: 2 additions & 1 deletion supervisor/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def change_state(self, new_state, expected=True):
self.state = new_state
if new_state == ProcessStates.BACKOFF:
now = time.time()
self.backoff += 1
if self.backoff < self.config.maxbackoff or self.config.maxbackoff == 0:
self.backoff += self.config.backoffincrement
self.delay = now + self.backoff

event_class = self.event_map.get(new_state)
Expand Down

0 comments on commit 40a9af2

Please sign in to comment.