Skip to content

Commit ab26970

Browse files
committed
Fix pidproxy with optional command args. Closes Supervisor#1418
1 parent bae9c3e commit ab26970

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

CHANGES.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
4.3.0 (Next Release)
2-
--------------------
1+
4.3.0.dev0 (Next Release)
2+
-------------------------
3+
4+
- Fixed a bug where ``pidproxy`` would not pass arguments to the command
5+
it runs.
36

47
4.2.2 (2021-02-26)
58
------------------

supervisor/pidproxy.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ class PidProxy:
1818
pid = None
1919

2020
def __init__(self, args):
21-
self.setsignals()
2221
try:
23-
self.pidfile, cmdargs = args[1], args[2:]
24-
self.command = os.path.abspath(cmdargs[0])
25-
self.cmdargs = cmdargs
22+
self.pidfile = args[1]
23+
command_and_cmdargs = args[2:]
24+
self.command = os.path.abspath(command_and_cmdargs[0])
25+
self.cmdargs = command_and_cmdargs[1:]
2626
except (ValueError, IndexError):
2727
self.usage()
2828
sys.exit(1)
2929

3030
def go(self):
31+
self.setsignals()
3132
self.pid = os.spawnv(os.P_NOWAIT, self.command, self.cmdargs)
3233
while 1:
3334
time.sleep(5)

supervisor/tests/test_pidproxy.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import unittest
3+
4+
class PidProxyTests(unittest.TestCase):
5+
def _getTargetClass(self):
6+
from supervisor.pidproxy import PidProxy
7+
return PidProxy
8+
9+
def _makeOne(self, *arg, **kw):
10+
return self._getTargetClass()(*arg, **kw)
11+
12+
def test_ctor_parses_args(self):
13+
args = ["pidproxy.py", "/path/to/pidfile", "./cmd", "-arg1", "-arg2"]
14+
pp = self._makeOne(args)
15+
self.assertEqual(pp.pidfile, "/path/to/pidfile")
16+
self.assertEqual(pp.command, os.path.abspath("./cmd"))
17+
self.assertEqual(pp.cmdargs, ["-arg1", "-arg2"])

0 commit comments

Comments
 (0)