diff --git a/supervisor/options.py b/supervisor/options.py index 271735200..cdb7e331f 100644 --- a/supervisor/options.py +++ b/supervisor/options.py @@ -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')) @@ -1041,6 +1043,8 @@ def get(section, opt, *args, **kwargs): autorestart=autorestart, startsecs=startsecs, startretries=startretries, + maxbackoff=maxbackoff, + backoffincrement=backoffincrement, uid=uid, stdout_logfile=logfiles['stdout_logfile'], stdout_capture_maxbytes = stdout_cmaxbytes, @@ -1870,6 +1874,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', diff --git a/supervisor/process.py b/supervisor/process.py index b394be812..0e233eadc 100644 --- a/supervisor/process.py +++ b/supervisor/process.py @@ -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) diff --git a/supervisor/tests/base.py b/supervisor/tests/base.py index f608b2bea..e687748ab 100644 --- a/supervisor/tests/base.py +++ b/supervisor/tests/base.py @@ -507,6 +507,7 @@ class DummyPConfig: def __init__(self, options, name, command, directory=None, umask=None, priority=999, autostart=True, autorestart=True, startsecs=10, startretries=999, + maxbackoff=0, backoffincrement=1, uid=None, stdout_logfile=None, stdout_capture_maxbytes=0, stdout_events_enabled=False, stdout_logfile_backups=0, stdout_logfile_maxbytes=0, @@ -526,6 +527,8 @@ def __init__(self, options, name, command, directory=None, umask=None, self.autorestart = autorestart self.startsecs = startsecs self.startretries = startretries + self.maxbackoff = maxbackoff + self.backoffincrement = backoffincrement self.uid = uid self.stdout_logfile = stdout_logfile self.stdout_capture_maxbytes = stdout_capture_maxbytes diff --git a/supervisor/tests/test_options.py b/supervisor/tests/test_options.py index 4f3ff71de..a809b24d7 100644 --- a/supervisor/tests/test_options.py +++ b/supervisor/tests/test_options.py @@ -3419,6 +3419,7 @@ def _makeOne(self, *arg, **kw): for name in ('name', 'command', 'directory', 'umask', 'priority', 'autostart', 'autorestart', 'startsecs', 'startretries', 'uid', + 'maxbackoff', 'backoffincrement', 'stdout_logfile', 'stdout_capture_maxbytes', 'stdout_events_enabled', 'stdout_syslog', 'stderr_logfile', 'stderr_capture_maxbytes', @@ -3517,6 +3518,7 @@ def _makeOne(self, *arg, **kw): for name in ('name', 'command', 'directory', 'umask', 'priority', 'autostart', 'autorestart', 'startsecs', 'startretries', 'uid', + 'maxbackoff', 'backoffincrement', 'stdout_logfile', 'stdout_capture_maxbytes', 'stdout_events_enabled', 'stdout_syslog', 'stderr_logfile', 'stderr_capture_maxbytes', @@ -3565,6 +3567,7 @@ def _makeOne(self, *arg, **kw): for name in ('name', 'command', 'directory', 'umask', 'priority', 'autostart', 'autorestart', 'startsecs', 'startretries', 'uid', + 'maxbackoff', 'backoffincrement', 'stdout_logfile', 'stdout_capture_maxbytes', 'stdout_events_enabled', 'stdout_syslog', 'stderr_logfile', 'stderr_capture_maxbytes', diff --git a/supervisor/tests/test_supervisord.py b/supervisor/tests/test_supervisord.py index 4099bba6c..e1111fa46 100644 --- a/supervisor/tests/test_supervisord.py +++ b/supervisor/tests/test_supervisord.py @@ -377,6 +377,7 @@ def make_pconfig(name, command, **params): 'name': name, 'command': command, 'directory': None, 'umask': None, 'priority': 999, 'autostart': True, 'autorestart': True, 'startsecs': 10, 'startretries': 999, + 'maxbackoff': 0, 'backoffincrement': 1, 'uid': None, 'stdout_logfile': None, 'stdout_capture_maxbytes': 0, 'stdout_events_enabled': False, 'stdout_logfile_backups': 0, 'stdout_logfile_maxbytes': 0, @@ -446,6 +447,7 @@ def make_pconfig(name, command, **params): 'name': name, 'command': command, 'directory': None, 'umask': None, 'priority': 999, 'autostart': True, 'autorestart': True, 'startsecs': 10, 'startretries': 999, + 'maxbackoff': 0, 'backoffincrement': 1, 'uid': None, 'stdout_logfile': None, 'stdout_capture_maxbytes': 0, 'stdout_events_enabled': False, 'stdout_logfile_backups': 0, 'stdout_logfile_maxbytes': 0,