From 8bda8d41109036e832943f848d96ea1012d9e1e1 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 27 Mar 2021 11:13:38 +0100 Subject: [PATCH] Add enable_celery_tasks config option --- doc/source/admin/galaxy_options.rst | 12 ++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 5 +++++ lib/galaxy/webapps/galaxy/config_schema.yml | 9 +++++++++ lib/galaxy/webapps/galaxy/controllers/user.py | 9 ++++++--- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 858fc8a21de..ddc26a4658c 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -4360,6 +4360,18 @@ :Type: str +~~~~~~~~~~~~~~~~~~~~~~~ +``enable_celery_tasks`` +~~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + Offload long-running tasks to a Celery task queue. Activate this + only if you have setup a Celery worker for Galaxy. For details, + see https://docs.galaxyproject.org/en/master/admin/production.html +:Default: ``false`` +:Type: bool + + ~~~~~~~~~~~~~~ ``use_pbkdf2`` ~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index e630d68e858..a65ad1df8fb 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -2159,6 +2159,11 @@ galaxy: # commented out line below). #amqp_internal_connection: sqlalchemy+sqlite:///./database/control.sqlite?isolation_level=IMMEDIATE + # Offload long-running tasks to a Celery task queue. Activate this + # only if you have setup a Celery worker for Galaxy. For details, see + # https://docs.galaxyproject.org/en/master/admin/production.html + #enable_celery_tasks: false + # Allow disabling pbkdf2 hashing of passwords for legacy situations. # This should normally be left enabled unless there is a specific # reason to disable it. diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index a6fd5931f03..378e1b9bb4b 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -3183,6 +3183,15 @@ mapping: will automatically create and use a separate sqlite database located in your /database folder (indicated in the commented out line below). + enable_celery_tasks: + type: bool + default: false + required: false + desc: | + Offload long-running tasks to a Celery task queue. + Activate this only if you have setup a Celery worker for Galaxy. + For details, see https://docs.galaxyproject.org/en/master/admin/production.html + use_pbkdf2: type: bool default: true diff --git a/lib/galaxy/webapps/galaxy/controllers/user.py b/lib/galaxy/webapps/galaxy/controllers/user.py index 29bba4aa2f2..a3c042cb6f4 100644 --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -222,9 +222,12 @@ class User(BaseUIController, UsesFormDefinitionsMixin, CreatesApiKeysMixin): if message: return self.message_exception(trans, message) if trans.user: - # Queue a quota recalculation (async) task -- this takes a - # while sometimes, so we don't want to block on logout. - recalculate_user_disk_usage.delay(user_id=trans.user.id) + if trans.app.config.enable_celery_tasks: + # Queue a quota recalculation (async) task -- this takes a + # while sometimes, so we don't want to block on logout. + recalculate_user_disk_usage.delay(user_id=trans.user.id) + else: + trans.user.calculate_and_set_disk_usage() # Since logging an event requires a session, we'll log prior to ending the session trans.log_event("User logged out") trans.handle_user_logout(logout_all=logout_all)