Добавил очередь
This commit is contained in:
24
app/core/celery.py
Normal file
24
app/core/celery.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from celery import Celery
|
||||
|
||||
from app.core.config import REDIS_URL, ssl_options
|
||||
|
||||
|
||||
celery_app = Celery(
|
||||
"celery_worker",
|
||||
broker=f"{REDIS_URL}/0",
|
||||
backend=f"{REDIS_URL}/1",
|
||||
)
|
||||
|
||||
|
||||
celery_app.conf.update(
|
||||
broker_use_ssl=ssl_options,
|
||||
redis_backend_use_ssl=ssl_options,
|
||||
task_serializer=["json"],
|
||||
result_serializer=["json"],
|
||||
accept_content=["json"],
|
||||
enable_utc=True,
|
||||
timezone="UTC",
|
||||
broker_connection_retry_on_startup=True,
|
||||
task_acks_late=True,
|
||||
task_reject_on_worker_lost=True,
|
||||
)
|
||||
32
app/core/config.py
Normal file
32
app/core/config.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import ssl
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
S3_ACCESS_KEY: str
|
||||
S3_SECRET_KEY: str
|
||||
S3_BUCKET_NAME: str
|
||||
S3_ENDPOINT_URL: str
|
||||
S3_REGION_NAME: str
|
||||
S3_SIGNATURE_VERSION: str
|
||||
|
||||
REDIS_HOST: str
|
||||
REDIS_PORT: str
|
||||
REDIS_PASSWORD: str
|
||||
|
||||
BASE_DIR: Path = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
model_config = SettingsConfigDict(env_file=BASE_DIR / ".env")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
REDIS_URL = (
|
||||
f"redis://:{settings.REDIS_PASSWORD}@{settings.REDIS_HOST}:{settings.REDIS_PORT}"
|
||||
)
|
||||
|
||||
|
||||
ssl_options = {"ssl_cert_reqs": ssl.CERT_NONE}
|
||||
Reference in New Issue
Block a user