From 84af02fbc657de3f728aa1282a3ae0828a552de0 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 17 Apr 2018 13:58:37 +0200 Subject: [PATCH] Allow to override the default sys.executable value (due to Windows service) --- circus/arbiter.py | 14 ++++++++------ circus/config.py | 4 +++- circus/plugins/__init__.py | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/circus/arbiter.py b/circus/arbiter.py index ac190da7e..81f8ddf82 100644 --- a/circus/arbiter.py +++ b/circus/arbiter.py @@ -90,7 +90,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, ssh_server=None, proc_name='circusd', pidfile=None, loglevel=None, logoutput=None, loggerconfig=None, fqdn_prefix=None, umask=None, endpoint_owner=None, - papa_endpoint=None): + papa_endpoint=None, py_exe=None): self.watchers = watchers self.endpoint = endpoint @@ -107,6 +107,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, self.loggerconfig = loggerconfig self.umask = umask self.endpoint_owner = endpoint_owner + self.py_exe = py_exe or sys.executable self._running = False try: # getfqdn appears to fail in Python3.3 in the unittest @@ -171,7 +172,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, cmd += ' --log-level ' + self.loglevel if self.logoutput: cmd += ' --log-output ' + self.logoutput - stats_watcher = Watcher('circusd-stats', cmd=sys.executable, + stats_watcher = Watcher('circusd-stats', cmd=self.py_exe, args=cmd, use_sockets=True, singleton=True, stdout_stream=self.stdout_stream, @@ -205,7 +206,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, cmd += ' --ssh %s' % ssh_server # Adding the watcher - httpd_watcher = Watcher('circushttpd', cmd=sys.executable, + httpd_watcher = Watcher('circushttpd', cmd=self.py_exe, args=cmd, use_sockets=use_sockets, singleton=True, stdout_stream=self.stdout_stream, @@ -222,7 +223,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, if plugins is not None: for plugin in plugins: fqn = plugin['use'] - cmd, args = get_plugin_cmd(plugin, self.endpoint, + cmd, args = get_plugin_cmd(self.py_exe, plugin, self.endpoint, self.pubsub_endpoint, self.check_delay, ssh_server, debug=self.debug, @@ -277,7 +278,7 @@ def get_plugin_config(self, config, name): for i in config.get('plugins', []): if i['name'] == name: cfg = i.copy() - cmd, args = get_plugin_cmd(cfg, self.endpoint, + cmd, args = get_plugin_cmd(self.py_exe, cfg, self.endpoint, self.pubsub_endpoint, self.check_delay, self.ssh_server, debug=self.debug) @@ -472,7 +473,8 @@ def load_from_config(cls, config_file, loop=None): loggerconfig=cfg.get('loggerconfig', None), fqdn_prefix=cfg.get('fqdn_prefix', None), umask=cfg['umask'], - endpoint_owner=cfg.get('endpoint_owner', None)) + endpoint_owner=cfg.get('endpoint_owner', None), + py_exe=cfg.get('py_exe', sys.executable)) # store the cfg which will be used, so it can be used later # for checking if the cfg has been changed diff --git a/circus/config.py b/circus/config.py index aed1d78c8..2c1e2d7ac 100644 --- a/circus/config.py +++ b/circus/config.py @@ -1,5 +1,6 @@ import glob import os +import sys import signal import warnings from fnmatch import fnmatch @@ -183,7 +184,8 @@ def get_config(config_file): config['logoutput'] = dget('circus', 'logoutput') config['loggerconfig'] = dget('circus', 'loggerconfig', None) config['fqdn_prefix'] = dget('circus', 'fqdn_prefix', None, str) - config['papa_endpoint'] = dget('circus', 'fqdn_prefix', None, str) + config['papa_endpoint'] = dget('circus', 'papa_endpoint', None, str) + config['py_exe'] = dget('circus', 'py_exe', sys.executable, str) # Initialize watchers, plugins & sockets to manage watchers = [] diff --git a/circus/plugins/__init__.py b/circus/plugins/__init__.py index 8c073fc98..af0bb6445 100644 --- a/circus/plugins/__init__.py +++ b/circus/plugins/__init__.py @@ -179,7 +179,7 @@ def _str2cfg(data): return cfg -def get_plugin_cmd(config, endpoint, pubsub, check_delay, ssh_server, +def get_plugin_cmd(py_exe, config, endpoint, pubsub, check_delay, ssh_server, debug=False, loglevel=None, logoutput=None): fqn = config['use'] # makes sure the name exists @@ -202,7 +202,7 @@ def get_plugin_cmd(config, endpoint, pubsub, check_delay, ssh_server, if logoutput: cmd += ' --log-output ' + logoutput cmd += ' %s' % fqn - return (sys.executable, cmd) + return (py_exe, cmd) def main():