Skip to content

Commit 16912f0

Browse files
committed
Add value of autorestart= to getAllConfigInfo()
Closes #1674
1 parent 18c4f6b commit 16912f0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
4.4.0.dev0 (Next Release)
22
-------------------------
33

4+
- Fixed a bug where the XML-RPC method ``supervisor.getAllConfigInfo()``
5+
did not return the value of the ``autorestart`` program option.
6+
47
- Parsing ``environment=`` in the config file now uses ``shlex`` in POSIX
58
mode instead of legacy mode to allow for escaped quotes in the values.
69
However, on Python 2 before 2.7.13 and Python 3 before 3.5.3, POSIX mode

supervisor/rpcinterface.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from supervisor.datatypes import (
1212
Automatic,
13+
RestartWhenExitUnexpected,
1314
signal_number,
1415
)
1516

@@ -568,6 +569,7 @@ def getAllConfigInfo(self):
568569
inuse = gconfig.name in self.supervisord.process_groups
569570
for pconfig in gconfig.process_configs:
570571
d = {'autostart': pconfig.autostart,
572+
'autorestart': pconfig.autorestart,
571573
'directory': pconfig.directory,
572574
'uid': pconfig.uid,
573575
'command': pconfig.command,
@@ -597,9 +599,16 @@ def getAllConfigInfo(self):
597599
'stderr_syslog': pconfig.stderr_syslog,
598600
'serverurl': pconfig.serverurl,
599601
}
602+
600603
# no support for these types in xml-rpc
601-
d.update((k, 'auto') for k, v in d.items() if v is Automatic)
602-
d.update((k, 'none') for k, v in d.items() if v is None)
604+
for k, v in d.items():
605+
if v is Automatic:
606+
d[k] = "auto"
607+
elif v is None:
608+
d[k] = "none"
609+
elif v is RestartWhenExitUnexpected:
610+
d[k] = "unexpected"
611+
603612
configinfo.append(d)
604613

605614
configinfo.sort(key=lambda r: r['name'])

supervisor/tests/test_rpcinterfaces.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from supervisor.compat import as_string, PY2
1919
from supervisor.datatypes import Automatic
20+
from supervisor.datatypes import RestartWhenExitUnexpected
2021

2122
class TestBase(unittest.TestCase):
2223
def setUp(self):
@@ -1146,10 +1147,12 @@ def test_getAllConfigInfo(self):
11461147
supervisord = DummySupervisor(options, 'foo')
11471148

11481149
pconfig1 = DummyPConfig(options, 'process1', __file__,
1150+
autorestart=False,
11491151
stdout_logfile=Automatic,
11501152
stderr_logfile=Automatic,
11511153
)
11521154
pconfig2 = DummyPConfig(options, 'process2', __file__,
1155+
autorestart=RestartWhenExitUnexpected,
11531156
stdout_logfile=None,
11541157
stderr_logfile=None,
11551158
)
@@ -1160,6 +1163,7 @@ def test_getAllConfigInfo(self):
11601163
interface = self._makeOne(supervisord)
11611164
configs = interface.getAllConfigInfo()
11621165
self.assertEqual(configs[0]['autostart'], True)
1166+
self.assertEqual(configs[0]['autorestart'], False)
11631167
self.assertEqual(configs[0]['stopwaitsecs'], 10)
11641168
self.assertEqual(configs[0]['stdout_events_enabled'], False)
11651169
self.assertEqual(configs[0]['stderr_events_enabled'], False)
@@ -1187,6 +1191,7 @@ def test_getAllConfigInfo(self):
11871191
assert 'test_rpcinterfaces.py' in configs[0]['command']
11881192

11891193
self.assertEqual(configs[1]['autostart'], True)
1194+
self.assertEqual(configs[1]['autorestart'], "unexpected")
11901195
self.assertEqual(configs[1]['stopwaitsecs'], 10)
11911196
self.assertEqual(configs[1]['stdout_events_enabled'], False)
11921197
self.assertEqual(configs[1]['stderr_events_enabled'], False)

0 commit comments

Comments
 (0)