From 7d3ce4e7dab93f1bb0a88153db8c9b3bef18a9af Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 28 Nov 2023 14:34:57 -0300 Subject: [PATCH] Refactor Celery configuration to support both Redis and RabbitMQ --- src/backend/langflow/core/celeryconfig.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/core/celeryconfig.py b/src/backend/langflow/core/celeryconfig.py index 35d51bba0..128139071 100644 --- a/src/backend/langflow/core/celeryconfig.py +++ b/src/backend/langflow/core/celeryconfig.py @@ -3,12 +3,16 @@ import os langflow_redis_host = os.environ.get("LANGFLOW_REDIS_HOST") langflow_redis_port = os.environ.get("LANGFLOW_REDIS_PORT") -if "BROKER_URL" in os.environ and "RESULT_BACKEND" in os.environ: - # RabbitMQ - broker_url = os.environ.get("BROKER_URL", "amqp://localhost") - result_backend = os.environ.get("RESULT_BACKEND", "redis://localhost:6379/0") -elif langflow_redis_host and langflow_redis_port: +# broker default user + +if langflow_redis_host and langflow_redis_port: broker_url = 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 accept_content = ["json", "pickle"]