# HG changeset patch # User Mads Kiilerich # Date 1604771397 -3600 # Node ID e0f7da1d3c56d91a753a9e4d3402c6feb61447ee # Parent aa5cd5e446215cbe6e12345cd5719b1ad8e957b1 celery: change celery-run to not take a whole app - take a config file, and then initialize app A step towards a better future ... diff -r aa5cd5e44621 -r e0f7da1d3c56 kallithea/bin/kallithea_cli_celery.py --- 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))