celery: improve errors handling and logging

This commit is contained in:
RhodeCode Admin 2023-01-31 10:07:10 +01:00
parent 07bf79ea48
commit a672643796
5 changed files with 12 additions and 6 deletions

View file

@ -383,7 +383,7 @@ file_store.storage_path = %(here)s/data/file_store
; CELERY CONFIG
; #############
; manually run celery: /path/to/celery worker -E --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
; manually run celery: /path/to/celery worker --task-events --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
use_celery = false

View file

@ -334,7 +334,7 @@ file_store.storage_path = %(here)s/data/file_store
; CELERY CONFIG
; #############
; manually run celery: /path/to/celery worker -E --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
; manually run celery: /path/to/celery worker --task-events --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
use_celery = false

View file

@ -21,10 +21,11 @@
Celery loader, run with::
celery worker \
--task-events \
--beat \
--app rhodecode.lib.celerylib.loader \
--scheduler rhodecode.lib.celerylib.scheduler.RcScheduler \
--loglevel DEBUG --ini=._dev/dev.ini
--loglevel DEBUG --ini=.dev/dev.ini
"""
import os
import logging
@ -134,7 +135,10 @@ def on_preload_parsed(options, **kwargs):
ini_file_glob = ini_location
log.debug('Bootstrapping RhodeCode application...')
env = bootstrap(ini_location, options=options)
try:
env = bootstrap(ini_location, options=options)
except Exception:
log.exception('Failed to bootstrap RhodeCode APP')
celery_settings = get_celery_config(env['registry'].settings)
setup_celery_app(
@ -262,6 +266,8 @@ class RequestContextTask(Task):
""" queue the job to run (we are in web request context here) """
req = get_current_request()
log.debug('Running Task: %s with class: %s. Request: %s Class: %s',
self, self.__class__, req, req.__class__)
# web case
if hasattr(req, 'user'):

View file

@ -39,6 +39,6 @@ class Command(BasePasterCommand):
pass
def command(self):
cmd = 'celery worker --beat --app rhodecode.lib.celerylib.loader --loglevel DEBUG --ini=%s' % self.path_to_ini_file
cmd = 'celery worker --task-events --beat --app rhodecode.lib.celerylib.loader --loglevel DEBUG --ini=%s' % self.path_to_ini_file
raise Exception('This Command is deprecated please run: %s' % cmd)

View file

@ -300,7 +300,7 @@ file_store.storage_path = %(here)s/data/file_store
; CELERY CONFIG
; #############
; manually run celery: /path/to/celery worker -E --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
; manually run celery: /path/to/celery worker --task-events --beat --app rhodecode.lib.celerylib.loader --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler --loglevel DEBUG --ini /path/to/rhodecode.ini
use_celery = false