Browse Source

Add command option --executable

Bert Vanderbauwhede 10 years ago
parent
commit
21b86d3e9e
3 changed files with 12 additions and 3 deletions
  1. 5 0
      celery/bin/base.py
  2. 4 1
      celery/bin/celeryd_detach.py
  3. 3 2
      celery/bin/multi.py

+ 5 - 0
celery/bin/base.py

@@ -63,6 +63,10 @@ in any command that also has a `--detach` option.
 
 
     Optional directory to change to after detaching.
     Optional directory to change to after detaching.
 
 
+.. cmdoption:: --executable
+
+    Executable to use for the detached process.
+
 """
 """
 from __future__ import absolute_import, print_function, unicode_literals
 from __future__ import absolute_import, print_function, unicode_literals
 
 
@@ -651,4 +655,5 @@ def daemon_options(default_pidfile=None, default_logfile=None):
         Option('--uid', default=None),
         Option('--uid', default=None),
         Option('--gid', default=None),
         Option('--gid', default=None),
         Option('--umask', default=None),
         Option('--umask', default=None),
+        Option('--executable', default=None),
     )
     )

+ 4 - 1
celery/bin/celeryd_detach.py

@@ -38,11 +38,14 @@ OPTION_LIST = daemon_options(default_pidfile='celeryd.pid') + (
 
 
 
 
 def detach(path, argv, logfile=None, pidfile=None, uid=None,
 def detach(path, argv, logfile=None, pidfile=None, uid=None,
-           gid=None, umask=None, working_directory=None, fake=False, app=None):
+           gid=None, umask=None, working_directory=None, fake=False, app=None,
+           executable=None):
     fake = 1 if C_FAKEFORK else fake
     fake = 1 if C_FAKEFORK else fake
     with detached(logfile, pidfile, uid, gid, umask, working_directory, fake,
     with detached(logfile, pidfile, uid, gid, umask, working_directory, fake,
                   after_forkers=False):
                   after_forkers=False):
         try:
         try:
+            if executable is not None:
+                path = executable
             os.execv(path, [path] + argv)
             os.execv(path, [path] + argv)
         except Exception:
         except Exception:
             if app is None:
             if app is None:

+ 3 - 2
celery/bin/multi.py

@@ -250,7 +250,7 @@ class MultiTool(object):
         self.note('> Starting nodes...')
         self.note('> Starting nodes...')
         for node in multi_args(p, cmd):
         for node in multi_args(p, cmd):
             self.note('\t> {0}: '.format(node.name), newline=False)
             self.note('\t> {0}: '.format(node.name), newline=False)
-            retcode = self.waitexec(node.argv)
+            retcode = self.waitexec(node.argv, path=p.options['--executable'])
             self.note(retcode and self.FAILED or self.OK)
             self.note(retcode and self.FAILED or self.OK)
             retcodes.append(retcode)
             retcodes.append(retcode)
         self.retcode = int(any(retcodes))
         self.retcode = int(any(retcodes))
@@ -262,6 +262,7 @@ class MultiTool(object):
             '--cmd',
             '--cmd',
             '-m {0}'.format(celery_exe('worker', '--detach')),
             '-m {0}'.format(celery_exe('worker', '--detach')),
         )
         )
+        _setdefaultopt(p.options, ['--executable'], sys.executable)
 
 
     def signal_node(self, nodename, pid, sig):
     def signal_node(self, nodename, pid, sig):
         try:
         try:
@@ -382,7 +383,7 @@ class MultiTool(object):
         def on_node_shutdown(nodename, argv, pid):
         def on_node_shutdown(nodename, argv, pid):
             self.note(self.colored.blue(
             self.note(self.colored.blue(
                 '> Restarting node {0}: '.format(nodename)), newline=False)
                 '> Restarting node {0}: '.format(nodename)), newline=False)
-            retval = self.waitexec(argv)
+            retval = self.waitexec(argv, path=p.options['--executable'])
             self.note(retval and self.FAILED or self.OK)
             self.note(retval and self.FAILED or self.OK)
             retvals.append(retval)
             retvals.append(retval)