Skip to content

Commit

Permalink
celery
Browse files Browse the repository at this point in the history
  • Loading branch information
i-oden committed Jan 9, 2025
1 parent 281edc9 commit 7ffaa7f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import sqlalchemy
import structlog
import werkzeug
from celery import Celery

####################################################################################################
# GLOBAL VARIABLES ############################################################## GLOBAL VARIABLES #
Expand Down Expand Up @@ -62,6 +63,8 @@
# Migration
migrate = flask_migrate.Migrate()

# Celery
celery = Celery()

####################################################################################################
# FUNCTIONS ############################################################################ FUNCTIONS #
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions dds_web/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7ffaa7f

Please sign in to comment.