circus-tent / circus

A Process & Socket Manager built with zmq
http://circus.readthedocs.org/
Other
1.55k stars 258 forks source link

Can't 'use_papa' programmatically #1081

Closed mercma closed 6 years ago

mercma commented 6 years ago

I am unable to call 'use_papa' programmatically Simple example:

from circus import get_arbiter

myprogram = {"cmd": "python3 exec.py", "use_papa": True, "numprocesses": 1, "name": "exec.py"}
arbiter = get_arbiter([myprogram])
try:
    arbiter.start()
finally:
    arbiter.stop()

The above python will not start the app using papa. The following fixes the issue.

diff --git a/circus/commands/util.py b/circus/commands/util.py
index 416919d..fcb1b54 100644
--- a/circus/commands/util.py
+++ b/circus/commands/util.py
@@ -59,6 +59,8 @@ def convert_option(key, val):
         return util.to_bool(val)
     elif key == "close_child_stderr":
         return util.to_bool(val)
+    elif key == "use_papa":
+        return util.to_bool(val)
      elif key.startswith('stderr_stream.') or key.startswith('stdout_stream.'):
         subkey = key.split('.', 1)[-1]
         if subkey in ('max_bytes', 'backup_count'):
@@ -99,7 +101,7 @@ def validate_option(key, val):
                   'max_retry', 'graceful_timeout', 'stdout_stream',
                   'stderr_stream', 'max_age', 'max_age_variance', 'respawn',
                   'singleton', 'hooks', 'close_child_stdin',
-                  'close_child_stdout', 'close_child_stderr')
+                  'close_child_stdout', 'close_child_stderr', 'use_papa')

     valid_prefixes = ('stdout_stream.', 'stderr_stream.', 'hooks.', 'rlimit_')
k4nar commented 6 years ago

@mercma : Thanks for the patch! Could you open a pull-request with it (and possibly with a test :) ).

mercma commented 6 years ago

@k4nar : I created a pull request, but not sure exactly what you are looking for regarding "a test"? Please forgive and/or educate me if I have done something incorrectly, this is my first time.

k4nar commented 6 years ago

@mercma : No worry, I think we don't really need a test for this one. I've merged it as it is.