Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/ai_analysis/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import logging
from celery import shared_task

logger = logging.getLogger(__name__)

@shared_task
def debug_task():
logger.info("Celery worker está funcionando!")
return "ok"

# para usar essa taks, chamamos a task junto com .delay()
3 changes: 3 additions & 0 deletions config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .celery import app as celery_app

__all__ = ("celery_app",)
8 changes: 8 additions & 0 deletions config/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
from celery import Celery

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

app = Celery("homematch")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()
9 changes: 9 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@

CORS_ALLOW_ALL_ORIGINS = True

# Celery
CELERY_BROKER_URL = config("CELERY_BROKER_URL", default="redis://redis:6379/0")
CELERY_RESULT_BACKEND = config("CELERY_RESULT_BACKEND", default="redis://redis:6379/0")
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"

# O redis vai enfileirar as tarefas e atribuir aos workers do celery.
# O celery vai ter seus workers que vão ter suas funções já pré definidas nos arquivos tasks.py
# Quando uma tarefa é terminada, o redis vai armazenar seu resultado
# Cloudflare R2
# Default to None so the app starts without R2 in local dev.
# AiVisionClient / boto3 will raise at the point of first use if unset.
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ services:
interval: 5s
retries: 5

redis:
image: redis:7-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
retries: 5


web:
build: .
command: python manage.py runserver 0.0.0.0:8000
Expand All @@ -28,5 +38,18 @@ services:
db:
condition: service_healthy

celery_worker:
build: .
command: celery -A config worker -l info
volumes:
- .:/app
env_file:
- .env
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy

volumes:
postgres_data:
12 changes: 0 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
Django==5.2
djangorestframework==3.16.0
djangorestframework-simplejwt==5.5.0
django-filter==25.1
django-cors-headers
psycopg2-binary==2.9.10
python-decouple==3.8
Markdown==3.8
pillow==11.2.1
boto3
openai
google-generativeai
Loading