chore: rename airtime-celery to libretime_worker
This commit is contained in:
parent
a3ad6cecc4
commit
39c6acdd8a
3 changed files with 0 additions and 0 deletions
43
worker/libretime_worker/celeryconfig.py
Normal file
43
worker/libretime_worker/celeryconfig.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
import os
|
||||
|
||||
from configobj import ConfigObj
|
||||
from kombu import Exchange, Queue
|
||||
|
||||
# Get the broker string from airtime.conf
|
||||
RMQ_CONFIG_SECTION = "rabbitmq"
|
||||
|
||||
|
||||
def get_rmq_broker():
|
||||
rmq_config = ConfigObj(os.environ["RMQ_CONFIG_FILE"])
|
||||
rmq_settings = parse_rmq_config(rmq_config)
|
||||
return "amqp://{username}:{password}@{host}:{port}/{vhost}".format(**rmq_settings)
|
||||
|
||||
|
||||
def parse_rmq_config(rmq_config):
|
||||
return {
|
||||
"host": rmq_config[RMQ_CONFIG_SECTION]["host"],
|
||||
"port": rmq_config[RMQ_CONFIG_SECTION]["port"],
|
||||
"username": rmq_config[RMQ_CONFIG_SECTION]["user"],
|
||||
"password": rmq_config[RMQ_CONFIG_SECTION]["password"],
|
||||
"vhost": rmq_config[RMQ_CONFIG_SECTION]["vhost"],
|
||||
}
|
||||
|
||||
|
||||
# Celery amqp settings
|
||||
BROKER_URL = get_rmq_broker()
|
||||
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
|
||||
CELERY_QUEUES = (
|
||||
Queue("podcast", exchange=Exchange("podcast"), routing_key="podcast"),
|
||||
Queue(exchange=Exchange("celeryresults"), auto_delete=True),
|
||||
)
|
||||
CELERY_EVENT_QUEUE_EXPIRES = 900 # RabbitMQ x-expire after 15 minutes
|
||||
|
||||
# Celery task settings
|
||||
CELERY_TASK_SERIALIZER = "json"
|
||||
CELERY_RESULT_SERIALIZER = "json"
|
||||
CELERY_ACCEPT_CONTENT = ["json"]
|
||||
CELERY_TIMEZONE = "Europe/Berlin"
|
||||
CELERY_ENABLE_UTC = True
|
Loading…
Add table
Add a link
Reference in a new issue