2
0
Fork 0

Add Celery

This commit is contained in:
Luca 2022-04-20 20:30:44 +02:00
parent d1c0c9e161
commit c0ee3eea02
7 changed files with 60 additions and 0 deletions

View File

@ -4,4 +4,5 @@
Dockerfile Dockerfile
README.md README.md
db.sqlite3 db.sqlite3
docker-compose.yml
env env

16
docker-compose.yml Normal file
View File

@ -0,0 +1,16 @@
---
services:
broker:
container_name: shiftregister_broker
image: rabbitmq:3-alpine
restart: unless-stopped
ports:
- 127.0.0.1:5672:5672
result_backend:
container_name: shiftregister_result_backend
image: redis:6-alpine
restart: unless-stopped
ports:
- 127.0.0.1:6379:6379

View File

@ -1,4 +1,24 @@
amqp==5.1.1
asgiref==3.5.0 asgiref==3.5.0
async-timeout==4.0.2
billiard==3.6.4.0
celery==5.2.6
click==8.1.2
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
Deprecated==1.2.13
Django==4.0.4 Django==4.0.4
kombu==5.2.4
librabbitmq==2.0.0
packaging==21.3
prompt-toolkit==3.0.29
psycopg2-binary==2.9.3 psycopg2-binary==2.9.3
pyparsing==3.0.8
pytz==2022.1
redis==4.2.2
six==1.16.0
sqlparse==0.4.2 sqlparse==0.4.2
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.0

View File

@ -0,0 +1,3 @@
from .celery import app as celery_app
__all__ = ("celery_app",)

View File

@ -0,0 +1,5 @@
from celery import shared_task
@shared_task
def test():
return 'Hello, Celery!'

11
shiftregister/celery.py Normal file
View File

@ -0,0 +1,11 @@
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shiftregister.settings")
app = Celery("shiftregister")
app.config_from_object("django.conf:settings", namespace='CELERY')
app.autodiscover_tasks()

View File

@ -137,3 +137,7 @@ STATICFILES_DIRS = [
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
CELERY_BROKER_URL = getenv("CELERY_BROKER_URL", "amqp://guest:guest@localhost:5672//")
CELERY_RESULT_BACKEND = getenv("CELERY_RESULT_BACKEND", "redis://")