Mercurial > kallithea
changeset 8828:e0f7da1d3c56
celery: change celery-run to not take a whole app - take a config file, and then initialize app
A step towards a better future ...
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 07 Nov 2020 18:49:57 +0100 |
parents | aa5cd5e44621 |
children | 01cb988e82a5 |
files | kallithea/bin/kallithea_cli_celery.py |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_celery.py Fri Jan 01 18:04:16 2021 +0100 +++ b/kallithea/bin/kallithea_cli_celery.py Sat Nov 07 18:49:57 2020 +0100 @@ -20,9 +20,9 @@ from kallithea.lib.utils2 import asbool -@cli_base.register_command(config_file_initialize_app=True) +@cli_base.register_command(needs_config_file=True) @click.argument('celery_args', nargs=-1) -def celery_run(celery_args): +def celery_run(celery_args, config): """Start Celery worker(s) for asynchronous tasks. This commands starts the Celery daemon which will spawn workers to handle @@ -33,9 +33,12 @@ by this CLI command. """ - if not asbool(kallithea.CONFIG.get('use_celery')): + if not asbool(config.get('use_celery')): raise Exception('Please set use_celery = true in .ini config ' 'file before running this command') + # do as config_file_initialize_app + kallithea.config.application.make_app(config.global_conf, **config.local_conf) + cmd = celery.bin.worker.worker(kallithea.CELERY_APP) return cmd.run_from_argv(None, command='celery-run -c CONFIG_FILE --', argv=list(celery_args))