Skip to content

Commit

Permalink
Allow to override the default sys.executable value (due to Windows se…
Browse files Browse the repository at this point in the history
…rvice)
  • Loading branch information
Yann Diorcet committed Apr 17, 2018
1 parent eea8485 commit 84af02f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions circus/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion circus/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob
import os
import sys
import signal
import warnings
from fnmatch import fnmatch
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions circus/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 84af02f

Please sign in to comment.