##// END OF EJS Templates
cli: convert 'gearbox celeryd' into 'kallithea-cli celery-run'...
Thomas De Schampheleire -
r7338:1d539bb1 default
parent child Browse files
Show More
@@ -307,7 +307,7 b' Celery. So for example setting `BROKER_H'
307
307
308 To start the Celery process, run::
308 To start the Celery process, run::
309
309
310 gearbox celeryd -c my.ini
310 kallithea-cli celery-run -c my.ini
311
311
312 Extra options to the Celery worker can be passed after ``--`` - see ``-- -h``
312 Extra options to the Celery worker can be passed after ``--`` - see ``-- -h``
313 for more info.
313 for more info.
@@ -21,7 +21,7 b' env USER=hg'
21 # env GROUP=hg
21 # env GROUP=hg
22
22
23 script
23 script
24 COMMAND="/var/hg/.virtualenvs/kallithea/bin/gearbox celeryd -c $APPINI -- --pidfile=$PIDFILE"
24 COMMAND="/var/hg/.virtualenvs/kallithea/bin/kallithea-cli celery-run -c $APPINI -- --pidfile=$PIDFILE"
25 if [ -z "$GROUP" ]; then
25 if [ -z "$GROUP" ]; then
26 exec sudo -u $USER $COMMAND
26 exec sudo -u $USER $COMMAND
27 else
27 else
@@ -16,6 +16,7 b''
16 from kallithea.bin.kallithea_cli_base import cli
16 from kallithea.bin.kallithea_cli_base import cli
17
17
18 # import commands (they will add themselves to the 'cli' object)
18 # import commands (they will add themselves to the 'cli' object)
19 import kallithea.bin.kallithea_cli_celery
19 import kallithea.bin.kallithea_cli_config
20 import kallithea.bin.kallithea_cli_config
20 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_extensions
22 import kallithea.bin.kallithea_cli_extensions
@@ -1,38 +1,39 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
14
3 import argparse
15 import click
16 import kallithea.bin.kallithea_cli_base as cli_base
4
17
5 import kallithea
18 import kallithea
6 from kallithea.lib.paster_commands.common import BasePasterCommand
7
8 __all__ = ['Command']
9
10
11 class Command(BasePasterCommand):
12 """Kallithea: Celery worker for asynchronous tasks"""
13
19
14 # Starts the celery worker using configuration from a paste.deploy
20 @cli_base.register_command(config_file_initialize_app=True)
15 # configuration file.
21 @click.argument('celery_args', nargs=-1)
22 def celery_run(celery_args):
23 """Start Celery worker(s) for asynchronous tasks.
16
24
17 def take_action(self, args):
25 This commands starts the Celery daemon which will spawn workers to handle
18 if not kallithea.CELERY_ON:
26 certain asynchronous tasks for Kallithea.
19 raise Exception('Please set use_celery = true in .ini config '
20 'file before running celeryd')
21
27
22 from kallithea.lib import celerypylons
28 Any extra arguments you pass to this command will be passed through to
23 cmd = celerypylons.worker.worker(celerypylons.app)
29 Celery. Use '--' before such extra arguments to avoid options to be parsed
24
30 by this CLI command.
25 celery_args = args.celery_args
31 """
26 if '--' in celery_args:
27 celery_args.remove('--')
28
29 return cmd.run_from_argv('kallithea celery worker', celery_args)
30
32
31 def get_parser(self, prog_name):
33 if not kallithea.CELERY_ON:
32 parser = super(Command, self).get_parser(prog_name)
34 raise Exception('Please set use_celery = true in .ini config '
35 'file before running this command')
33
36
34 parser.add_argument('celery_args', nargs=argparse.REMAINDER,
37 from kallithea.lib import celerypylons
35 help="Pass extra options to Celery after a '--' separator",
38 cmd = celerypylons.worker.worker(celerypylons.app)
36 )
39 return cmd.run_from_argv('kallithea celery worker', celery_args)
37
38 return parser
@@ -159,7 +159,6 b' setuptools.setup('
159 main = kallithea.config.middleware:make_app
159 main = kallithea.config.middleware:make_app
160
160
161 [gearbox.commands]
161 [gearbox.commands]
162 celeryd=kallithea.lib.paster_commands.celeryd:Command
163 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
162 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
164 """,
163 """,
165 )
164 )
General Comments 0
You need to be logged in to leave comments. Login now