2022-02-22 20:03:31 +01:00
|
|
|
from os import getenv
|
2021-06-03 15:20:39 +02:00
|
|
|
|
2015-06-09 20:02:29 +02:00
|
|
|
from kombu import Exchange, Queue
|
2022-07-26 14:18:41 +02:00
|
|
|
from libretime_shared.config import BaseConfig, GeneralConfig, RabbitMQConfig
|
2015-06-09 20:02:29 +02:00
|
|
|
|
|
|
|
|
2022-02-22 20:03:31 +01:00
|
|
|
class Config(BaseConfig):
|
2022-07-26 14:18:41 +02:00
|
|
|
general: GeneralConfig
|
2022-02-22 20:03:31 +01:00
|
|
|
rabbitmq: RabbitMQConfig = RabbitMQConfig()
|
2015-06-09 20:02:29 +02:00
|
|
|
|
|
|
|
|
2022-02-22 20:03:31 +01:00
|
|
|
LIBRETIME_CONFIG_FILEPATH = getenv("LIBRETIME_CONFIG_FILEPATH")
|
2015-06-12 18:31:55 +02:00
|
|
|
|
2022-08-12 15:12:39 +02:00
|
|
|
config = Config(LIBRETIME_CONFIG_FILEPATH)
|
2019-08-18 17:45:48 +02:00
|
|
|
|
2015-06-09 20:02:29 +02:00
|
|
|
# Celery amqp settings
|
2022-02-22 20:03:31 +01:00
|
|
|
BROKER_URL = config.rabbitmq.url
|
2019-08-18 17:45:48 +02:00
|
|
|
CELERY_RESULT_BACKEND = "amqp" # Use RabbitMQ as the celery backend
|
|
|
|
CELERY_RESULT_PERSISTENT = True # Persist through a broker restart
|
|
|
|
CELERY_TASK_RESULT_EXPIRES = 900 # Expire task results after 15 minutes
|
|
|
|
CELERY_RESULT_EXCHANGE = "celeryresults" # Default exchange - needed due to php-celery
|
2015-06-09 20:02:29 +02:00
|
|
|
CELERY_QUEUES = (
|
2024-04-13 19:12:45 +02:00
|
|
|
Queue("celery", exchange=Exchange("celery"), routing_key="celery"),
|
2019-08-18 17:45:48 +02:00
|
|
|
Queue("podcast", exchange=Exchange("podcast"), routing_key="podcast"),
|
|
|
|
Queue(exchange=Exchange("celeryresults"), auto_delete=True),
|
2015-06-09 20:02:29 +02:00
|
|
|
)
|
2019-08-18 17:45:48 +02:00
|
|
|
CELERY_EVENT_QUEUE_EXPIRES = 900 # RabbitMQ x-expire after 15 minutes
|
2015-06-09 20:02:29 +02:00
|
|
|
|
|
|
|
# Celery task settings
|
2019-08-18 17:45:48 +02:00
|
|
|
CELERY_TASK_SERIALIZER = "json"
|
|
|
|
CELERY_RESULT_SERIALIZER = "json"
|
|
|
|
CELERY_ACCEPT_CONTENT = ["json"]
|
2022-09-20 21:41:18 +02:00
|
|
|
CELERY_TIMEZONE = config.general.timezone
|