diff --git a/dds_web/__init__.py b/dds_web/__init__.py index 55d7e51cb..4334cec18 100644 --- a/dds_web/__init__.py +++ b/dds_web/__init__.py @@ -29,6 +29,7 @@ import sqlalchemy import structlog import werkzeug +from celery import Celery #################################################################################################### # GLOBAL VARIABLES ############################################################## GLOBAL VARIABLES # @@ -62,6 +63,8 @@ # Migration migrate = flask_migrate.Migrate() +# Celery +celery = Celery() #################################################################################################### # FUNCTIONS ############################################################################ FUNCTIONS # @@ -280,6 +283,10 @@ def load_user(user_id): # Initialize migrations migrate.init_app(app, db) + # Celery + celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"]) + celery.conf.update(app.config) + # initialize OIDC oauth.init_app(app) oauth.register( diff --git a/dds_web/config.py b/dds_web/config.py index be2aa4254..2636b1542 100644 --- a/dds_web/config.py +++ b/dds_web/config.py @@ -91,3 +91,6 @@ class Config(object): # Logging setup; 0 means no log rotation LOG_MAX_SIZE = os.environ.get("LOG_MAX_SIZE", 0x100000) LOG_BACKUP_COUNT = os.environ.get("LOG_BACKUP_COUNT", 15) + + CELERY_BROKER_URL = 'redis://localhost:6379/0' + CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7cda25b4a..e3196a9b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -174,3 +174,11 @@ services: - type: bind source: ../dds_cli target: /code + + worker: + build: + context: . + dockerfile: Dockerfiles/backend.Dockerfile + command: celery -A run.celery worker --loglevel=info + links: + - redis \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6a8f66aab..b615d189d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,11 +8,11 @@ blinker==1.4 boto3==1.20.47 botocore==1.23.47 cachetools==5.2.0 -celery==5.4.0 +celery[redis]==5.4.0 certifi==2024.7.4 cffi==1.15.0 charset-normalizer==2.0.11 -click==8.0.3 +click==8.1.2 # Celery requires >=8.1.2 cryptography==42.0.4 Deprecated==1.2.13 dnspython==2.2.0 @@ -53,7 +53,7 @@ python-dateutil==2.8.2 pytz==2021.3 pytz-deprecation-shim==0.1.0.post0 qrcode==7.3.1 -redis==4.5.5 +redis==4.6.0 # Celery requires != 4.5.5, <6.0.0, >=4.5.2 requests==2.32.0 requests_cache==0.9.4 rich==12.5.1 @@ -62,7 +62,7 @@ simplejson==3.17.6 six==1.16.0 SQLAlchemy==1.4.31 structlog==21.5.0 -tzdata==2021.5 +tzdata==2022.7 # Celery requires >=2022.7 tzlocal==4.1 urllib3==1.26.18 visitor==0.1.3