# HG changeset patch # User Mads Kiilerich # Date 2016-09-06 00:51:18 # Node ID cf73bd884a537c22c181bcaf5015dbd4f26c7d09 # Parent 7e7db11d4e4dc771e26990cf50651437f830f4c7 celeryd: move the celeryd paster command to the place where paster commands live Also, partial implementations of other Celery functionality is dropped. diff --git a/kallithea/lib/celerypylons/__init__.py b/kallithea/lib/celerypylons/__init__.py --- a/kallithea/lib/celerypylons/__init__.py +++ b/kallithea/lib/celerypylons/__init__.py @@ -33,4 +33,4 @@ os.environ['CELERY_LOADER'] = CELERYPYLO 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 diff --git a/kallithea/lib/celerypylons/commands.py b/kallithea/lib/paster_commands/celeryd.py rename from kallithea/lib/celerypylons/commands.py rename to kallithea/lib/paster_commands/celeryd.py --- a/kallithea/lib/celerypylons/commands.py +++ b/kallithea/lib/paster_commands/celeryd.py @@ -2,31 +2,29 @@ import kallithea from kallithea.lib.paster_commands.common import BasePasterCommand -from kallithea.lib.utils import Command, load_rcextensions - - +from kallithea.lib.utils import load_rcextensions from kallithea.lib.utils2 import str2bool -__all__ = ['CeleryDaemonCommand', 'CeleryBeatCommand', - 'CAMQPAdminCommand', 'CeleryEventCommand'] +__all__ = ['Command'] -class CeleryCommand(BasePasterCommand): - """Abstract class implements run methods needed for celery +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): - """ - 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()) + cmd = celerypylons.celeryd.WorkerCommand(celerypylons.app.app_or_default()) for x in cmd.get_options(): self.parser.add_option(x) @@ -42,60 +40,7 @@ class CeleryCommand(BasePasterCommand): 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()) + cmd = celerypylons.celeryd.WorkerCommand(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 diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -39,8 +39,6 @@ import warnings 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 diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -166,7 +166,7 @@ setuptools.setup( 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 """, )