changeset 6173:cf73bd884a53

celeryd: move the celeryd paster command to the place where paster commands live Also, partial implementations of other Celery functionality is dropped.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 06 Sep 2016 00:51:18 +0200
parents 7e7db11d4e4d
children 4f2e231df222
files kallithea/lib/celerypylons/__init__.py kallithea/lib/celerypylons/commands.py kallithea/lib/paster_commands/celeryd.py kallithea/lib/utils.py setup.py
diffstat 5 files changed, 48 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/celerypylons/__init__.py	Tue Sep 06 00:51:18 2016 +0200
+++ b/kallithea/lib/celerypylons/__init__.py	Tue Sep 06 00:51:18 2016 +0200
@@ -33,4 +33,4 @@
 import celery.app as app
 import celery.result as result
 from celery.task import task
-from celery.bin import camqadm, celerybeat, celeryd, celeryev
+from celery.bin import celeryd
--- a/kallithea/lib/celerypylons/commands.py	Tue Sep 06 00:51:18 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import kallithea
-from kallithea.lib.paster_commands.common import BasePasterCommand
-from kallithea.lib.utils import Command, load_rcextensions
-
-
-from kallithea.lib.utils2 import str2bool
-
-__all__ = ['CeleryDaemonCommand', 'CeleryBeatCommand',
-           'CAMQPAdminCommand', 'CeleryEventCommand']
-
-
-class CeleryCommand(BasePasterCommand):
-    """Abstract class implements run methods needed for celery
-
-    Starts the celery worker that uses a paste.deploy configuration
-    file.
-    """
-
-    def update_parser(self):
-        """
-        Abstract method.  Allows for the class's parser to be updated
-        before the superclass's `run` method is called.  Necessary to
-        allow options/arguments to be passed through to the underlying
-        celery command.
-        """
-        from kallithea.lib import celerypylons
-        cmd = self.celery_command(celerypylons.app.app_or_default())
-        for x in cmd.get_options():
-            self.parser.add_option(x)
-
-    def command(self):
-        from kallithea.lib import celerypylons
-        from pylons import config
-        try:
-            CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
-        except KeyError:
-            CELERY_ON = False
-
-        if not CELERY_ON:
-            raise Exception('Please set use_celery = true in .ini config '
-                            'file before running celeryd')
-        kallithea.CELERY_ON = CELERY_ON
-        load_rcextensions(config['here'])
-        cmd = self.celery_command(celerypylons.app.app_or_default())
-        return cmd.run(**vars(self.options))
-
-
-class CeleryDaemonCommand(CeleryCommand):
-    """Start the celery worker
-
-    Starts the celery worker that uses a paste.deploy configuration
-    file.
-    """
-    usage = 'CONFIG_FILE [celeryd options...]'
-    summary = __doc__.splitlines()[0]
-    description = "".join(__doc__.splitlines()[2:])
-
-    parser = Command.standard_parser(quiet=True)
-    celery_command = celerypylons.celeryd.WorkerCommand
-
-
-class CeleryBeatCommand(CeleryCommand):
-    """Start the celery beat server
-
-    Starts the celery beat server using a paste.deploy configuration
-    file.
-    """
-    usage = 'CONFIG_FILE [celerybeat options...]'
-    summary = __doc__.splitlines()[0]
-    description = "".join(__doc__.splitlines()[2:])
-
-    parser = Command.standard_parser(quiet=True)
-    celery_command = celerypylons.celerybeat.BeatCommand
-
-
-class CAMQPAdminCommand(CeleryCommand):
-    """CAMQP Admin
-
-    CAMQP celery admin tool.
-    """
-    usage = 'CONFIG_FILE [camqadm options...]'
-    summary = __doc__.splitlines()[0]
-    description = "".join(__doc__.splitlines()[2:])
-
-    parser = Command.standard_parser(quiet=True)
-    celery_command = celerypylons.camqadm.AMQPAdminCommand
-
-
-class CeleryEventCommand(CeleryCommand):
-    """Celery event command.
-
-    Capture celery events.
-    """
-    usage = 'CONFIG_FILE [celeryev options...]'
-    summary = __doc__.splitlines()[0]
-    description = "".join(__doc__.splitlines()[2:])
-
-    parser = Command.standard_parser(quiet=True)
-    celery_command = celerypylons.celeryev.EvCommand
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kallithea/lib/paster_commands/celeryd.py	Tue Sep 06 00:51:18 2016 +0200
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+
+import kallithea
+from kallithea.lib.paster_commands.common import BasePasterCommand
+from kallithea.lib.utils import load_rcextensions
+from kallithea.lib.utils2 import str2bool
+
+__all__ = ['Command']
+
+
+class Command(BasePasterCommand):
+    """Start the celery worker
+
+    Starts the celery worker that uses a paste.deploy configuration
+    file.
+    """
+
+    usage = 'CONFIG_FILE [celeryd options...]'
+    summary = __doc__.splitlines()[0]
+    description = "".join(__doc__.splitlines()[2:])
+    group_name = "Kallithea"
+
+    parser = BasePasterCommand.standard_parser(quiet=True)
+
+    def update_parser(self):
+        from kallithea.lib import celerypylons
+        cmd = celerypylons.celeryd.WorkerCommand(celerypylons.app.app_or_default())
+        for x in cmd.get_options():
+            self.parser.add_option(x)
+
+    def command(self):
+        from kallithea.lib import celerypylons
+        from pylons import config
+        try:
+            CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
+        except KeyError:
+            CELERY_ON = False
+
+        if not CELERY_ON:
+            raise Exception('Please set use_celery = true in .ini config '
+                            'file before running celeryd')
+        kallithea.CELERY_ON = CELERY_ON
+
+        load_rcextensions(config['here'])
+        cmd = celerypylons.celeryd.WorkerCommand(celerypylons.app.app_or_default())
+        return cmd.run(**vars(self.options))
--- a/kallithea/lib/utils.py	Tue Sep 06 00:51:18 2016 +0200
+++ b/kallithea/lib/utils.py	Tue Sep 06 00:51:18 2016 +0200
@@ -39,8 +39,6 @@
 from os.path import abspath
 from os.path import dirname
 
-from paste.script.command import Command, BadCommand
-
 from webhelpers.text import collapse, remove_formatting, strip_tags
 from beaker.cache import _cache_decorate
 
--- a/setup.py	Tue Sep 06 00:51:18 2016 +0200
+++ b/setup.py	Tue Sep 06 00:51:18 2016 +0200
@@ -166,7 +166,7 @@
     ishell=kallithea.lib.paster_commands.ishell:Command
     make-index=kallithea.lib.paster_commands.make_index:Command
     upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
-    celeryd=kallithea.lib.celerypylons.commands:CeleryDaemonCommand
+    celeryd=kallithea.lib.paster_commands.celeryd:Command
     install-iis=kallithea.lib.paster_commands.install_iis:Command
     """,
 )