Show More
@@ -307,7 +307,7 b' Celery. So for example setting `BROKER_H' | |||
|
307 | 307 | |
|
308 | 308 | To start the Celery process, run:: |
|
309 | 309 | |
|
310 |
|
|
|
310 | kallithea-cli celery-run -c my.ini | |
|
311 | 311 | |
|
312 | 312 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` |
|
313 | 313 | for more info. |
@@ -21,7 +21,7 b' env USER=hg' | |||
|
21 | 21 | # env GROUP=hg |
|
22 | 22 | |
|
23 | 23 | script |
|
24 |
COMMAND="/var/hg/.virtualenvs/kallithea/bin/ |
|
|
24 | COMMAND="/var/hg/.virtualenvs/kallithea/bin/kallithea-cli celery-run -c $APPINI -- --pidfile=$PIDFILE" | |
|
25 | 25 | if [ -z "$GROUP" ]; then |
|
26 | 26 | exec sudo -u $USER $COMMAND |
|
27 | 27 | else |
@@ -16,6 +16,7 b'' | |||
|
16 | 16 | from kallithea.bin.kallithea_cli_base import cli |
|
17 | 17 | |
|
18 | 18 | # import commands (they will add themselves to the 'cli' object) |
|
19 | import kallithea.bin.kallithea_cli_celery | |
|
19 | 20 | import kallithea.bin.kallithea_cli_config |
|
20 | 21 | import kallithea.bin.kallithea_cli_db |
|
21 | 22 | import kallithea.bin.kallithea_cli_extensions |
@@ -1,38 +1,39 b'' | |||
|
1 | 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 | 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 | |
|
15 | # configuration file. | |
|
20 | @cli_base.register_command(config_file_initialize_app=True) | |
|
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): | |
|
18 | if not kallithea.CELERY_ON: | |
|
19 | raise Exception('Please set use_celery = true in .ini config ' | |
|
20 | 'file before running celeryd') | |
|
25 | This commands starts the Celery daemon which will spawn workers to handle | |
|
26 | certain asynchronous tasks for Kallithea. | |
|
21 | 27 |
|
|
22 | from kallithea.lib import celerypylons | |
|
23 | cmd = celerypylons.worker.worker(celerypylons.app) | |
|
24 | ||
|
25 | celery_args = args.celery_args | |
|
26 | if '--' in celery_args: | |
|
27 | celery_args.remove('--') | |
|
28 | ||
|
29 | return cmd.run_from_argv('kallithea celery worker', celery_args) | |
|
28 | Any extra arguments you pass to this command will be passed through to | |
|
29 | Celery. Use '--' before such extra arguments to avoid options to be parsed | |
|
30 | by this CLI command. | |
|
31 | """ | |
|
30 | 32 | |
|
31 | def get_parser(self, prog_name): | |
|
32 | parser = super(Command, self).get_parser(prog_name) | |
|
33 | if not kallithea.CELERY_ON: | |
|
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, | |
|
35 | help="Pass extra options to Celery after a '--' separator", | |
|
36 | ) | |
|
37 | ||
|
38 | return parser | |
|
37 | from kallithea.lib import celerypylons | |
|
38 | cmd = celerypylons.worker.worker(celerypylons.app) | |
|
39 | return cmd.run_from_argv('kallithea celery worker', celery_args) |
General Comments 0
You need to be logged in to leave comments.
Login now