# HG changeset patch # User RhodeCode Admin # Date 2024-05-22 13:35:24 # Node ID 64d7f92c7feab5b4a8384d0cbc2df180b5b40461 # Parent 75bcbfe164754915da2bbbef684656dd052ef775 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)