Changeset - e0f7da1d3c56
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2020-11-07 18:49:57
mads@kiilerich.com
Grafted from: 2a6413cea44d
celery: change celery-run to not take a whole app - take a config file, and then initialize app

A step towards a better future ...
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_celery.py
Show inline comments
 
@@ -17,25 +17,28 @@ import click
 

	
 
import kallithea
 
import kallithea.bin.kallithea_cli_base as cli_base
 
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
 
    certain asynchronous tasks for Kallithea.
 

	
 
    Any extra arguments you pass to this command will be passed through to
 
    Celery. Use '--' before such extra arguments to avoid options to be parsed
 
    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))
0 comments (0 inline, 0 general)