-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcelery_app.py
More file actions
26 lines (20 loc) · 787 Bytes
/
celery_app.py
File metadata and controls
26 lines (20 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
from celery import Celery
from flask import Flask
from env_vars import PG_DB_USERNAME, PG_DB_PASSWORD, PG_DB_NAME, PG_DB_HOSTNAME
from persistance.models import db
from pathlib import Path
sys.path.append(str(Path(__file__).parent.absolute()))
app = Flask(__name__)
# Configure postgres db
app.config['SQLALCHEMY_DATABASE_URI'] = f'postgresql://{PG_DB_USERNAME}:{PG_DB_PASSWORD}@{PG_DB_HOSTNAME}/{PG_DB_NAME}'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
# Celery configuration
app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
celery = Celery(
app.name, # Replace with your Flask app name
broker=app.config['CELERY_BROKER_URL'], # Use Redis as the message broker
include=['jobs.tasks']
)
celery.conf.update(app.config)