# HG changeset patch # User RhodeCode Admin # Date 2024-05-22 13:35:24 # Node ID fcfc4234b8c7161308a0958f19cae28bffb871e9 # Parent ee39fc107907e7cc9852b81e37be2eb5d12bcb49 fix(celery): signal startup failure with sys.exit to recycle celery worker on errors diff --git a/rhodecode/lib/celerylib/loader.py b/rhodecode/lib/celerylib/loader.py --- a/rhodecode/lib/celerylib/loader.py +++ b/rhodecode/lib/celerylib/loader.py @@ -32,6 +32,7 @@ inspect_getargspec() inspect_formatargspec() # python3.11 inspect patches for backward compat on `paste` code +import sys import logging import importlib @@ -160,12 +161,12 @@ def _init_celery(app_type=''): try: env = bootstrap(ini_file, options=options) except Exception: - log.exception('Failed to bootstrap RhodeCode APP') + log.exception('Failed to bootstrap RhodeCode APP. ' + 'Probably there is another error present that prevents from running pyramid app') if not env: - raise EnvironmentError( - 'Failed to load pyramid ENV. ' - 'Probably there is another error present that prevents from running pyramid app') + # we use sys.exit here since we need to signal app startup failure for docker to restart the container and re-try + sys.exit(1) log.debug('Got Pyramid ENV: %s', env)