diff --git a/agenta-backend/agenta_backend/config.py b/agenta-backend/agenta_backend/config.py index 29f632e48e..56965077b3 100644 --- a/agenta-backend/agenta_backend/config.py +++ b/agenta-backend/agenta_backend/config.py @@ -14,14 +14,12 @@ os.environ["DOCKER_HUB_URL"] = toml_config["docker_hub_url"] os.environ["DOCKER_HUB_REPO_OWNER"] = toml_config["docker_hub_repo_owner"] os.environ["DOCKER_HUB_REPO_NAME"] = toml_config["docker_hub_repo_name"] -os.environ["REDIS_URL"] = toml_config["redis_url"] os.environ["DATABASE_MODE"] = os.environ.get("DATABASE_MODE", "v2") class Settings(BaseSettings): docker_registry_url: str registry: str - redis_url: str database_url: str docker_hub_url: str docker_hub_repo_owner: str diff --git a/agenta-backend/agenta_backend/config.toml b/agenta-backend/agenta_backend/config.toml index 325fd6004e..c5b0f0b5aa 100644 --- a/agenta-backend/agenta_backend/config.toml +++ b/agenta-backend/agenta_backend/config.toml @@ -1,7 +1,6 @@ docker_registry_url="registry:5001" registry="agentaai" database_url="sqlite:////db/deploy.db" -redis_url="redis://redis:6379/0" docker_hub_url="https://hub.docker.com/v2/repositories/{}/{}" docker_hub_repo_owner="agentaai" docker_hub_repo_name="templates_v2" diff --git a/agenta-backend/agenta_backend/services/app_manager.py b/agenta-backend/agenta_backend/services/app_manager.py index 57a5b2ce95..550d489d8c 100644 --- a/agenta-backend/agenta_backend/services/app_manager.py +++ b/agenta-backend/agenta_backend/services/app_manager.py @@ -26,7 +26,7 @@ deployment_manager, ) # noqa pylint: disable-all else: - from agenta_backend.services import deployment_manage + from agenta_backend.services import deployment_manager if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]: from agenta_backend.cloud.services import ( diff --git a/agenta-backend/agenta_backend/utils/redis_utils.py b/agenta-backend/agenta_backend/utils/redis_utils.py index 37fbd29fa9..3868a68a9b 100644 --- a/agenta-backend/agenta_backend/utils/redis_utils.py +++ b/agenta-backend/agenta_backend/utils/redis_utils.py @@ -1,14 +1,21 @@ +import os import redis -from agenta_backend.config import settings +from redis.exceptions import ConnectionError def redis_connection() -> redis.Redis: - """Returns a Redis client object connected to a Redis server specified - by the `redis_url` setting. + """Returns a client object for connecting to a Redis service specified \ + by the REDIS_URL environment variable. - Returns: - A Redis client object. + :return: a Redis client object. """ - redis_client = redis.from_url(url=settings.redis_url) + try: + redis_client = redis.from_url(url=os.environ.get("REDIS_URL", None)) + except ConnectionRefusedError: + raise ConnectionRefusedError( + "Refuse connecting to redis service. Kindly check redis url." + ) + except ConnectionError: + raise ConnectionError("Could not connect to redis service.") return redis_client diff --git a/docker-compose.gh.yml b/docker-compose.gh.yml index 2ec2f79b51..d5c0fabad9 100644 --- a/docker-compose.gh.yml +++ b/docker-compose.gh.yml @@ -15,6 +15,7 @@ services: image: ghcr.io/agenta-ai/agenta-backend environment: - MONGODB_URI=mongodb://username:password@mongo:27017 + - REDIS_URL=redis://redis:6379/0 - ENVIRONMENT=development - BARE_DOMAIN_NAME=${BARE_DOMAIN_NAME:-localhost} - DOMAIN_NAME=${DOMAIN_NAME:-http://localhost} diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 99ab3dc65b..ff4dbdbac3 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -14,6 +14,7 @@ services: build: ./agenta-backend environment: - MONGODB_URI=mongodb://username:password@mongo:27017 + - REDIS_URL=redis://redis:6379/0 - ALLOW_ORIGINS=${ALLOW_ORIGINS} - ENVIRONMENT=production - FEATURE_FLAG=oss diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 302ec22156..522ea4a1d2 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -6,6 +6,7 @@ services: container_name: agenta-backend-test environment: - MONGODB_URI=mongodb://username:password@mongo:27017/ + - REDIS_URL=redis://redis:6379/0 - ENVIRONMENT=development - DATABASE_MODE=test - FEATURE_FLAG=oss diff --git a/docker-compose.yml b/docker-compose.yml index 01d5f053c5..723707046c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: build: ./agenta-backend environment: - MONGODB_URI=mongodb://username:password@mongo:27017 + - REDIS_URL=redis://redis:6379/0 - ENVIRONMENT=development - DATABASE_MODE=v2 - BARE_DOMAIN_NAME=localhost