Refactor Celery configuration to support both
Redis and RabbitMQ
This commit is contained in:
parent
e08843485f
commit
7d3ce4e7da
1 changed files with 9 additions and 5 deletions
|
|
@ -3,12 +3,16 @@ import os
|
||||||
|
|
||||||
langflow_redis_host = os.environ.get("LANGFLOW_REDIS_HOST")
|
langflow_redis_host = os.environ.get("LANGFLOW_REDIS_HOST")
|
||||||
langflow_redis_port = os.environ.get("LANGFLOW_REDIS_PORT")
|
langflow_redis_port = os.environ.get("LANGFLOW_REDIS_PORT")
|
||||||
if "BROKER_URL" in os.environ and "RESULT_BACKEND" in os.environ:
|
# broker default user
|
||||||
# RabbitMQ
|
|
||||||
broker_url = os.environ.get("BROKER_URL", "amqp://localhost")
|
if langflow_redis_host and langflow_redis_port:
|
||||||
result_backend = os.environ.get("RESULT_BACKEND", "redis://localhost:6379/0")
|
|
||||||
elif langflow_redis_host and langflow_redis_port:
|
|
||||||
broker_url = f"redis://{langflow_redis_host}:{langflow_redis_port}/0"
|
broker_url = f"redis://{langflow_redis_host}:{langflow_redis_port}/0"
|
||||||
result_backend = f"redis://{langflow_redis_host}:{langflow_redis_port}/0"
|
result_backend = f"redis://{langflow_redis_host}:{langflow_redis_port}/0"
|
||||||
|
else:
|
||||||
|
# RabbitMQ
|
||||||
|
mq_user = os.environ.get("RABBITMQ_DEFAULT_USER", "langflow")
|
||||||
|
mq_password = os.environ.get("RABBITMQ_DEFAULT_PASS", "langflow")
|
||||||
|
broker_url = os.environ.get("BROKER_URL", f"amqp://{mq_user}:{mq_password}@localhost:5672//")
|
||||||
|
result_backend = os.environ.get("RESULT_BACKEND", "redis://localhost:6379/0")
|
||||||
# tasks should be json or pickle
|
# tasks should be json or pickle
|
||||||
accept_content = ["json", "pickle"]
|
accept_content = ["json", "pickle"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue