From a461b783b9065d32da98d634598847836c3ed81e Mon Sep 17 00:00:00 2001 From: Yury Kossakovsky Date: Thu, 22 May 2025 11:39:11 -0600 Subject: [PATCH] Enhance environment variable handling in start_services.py - Added load_dotenv() to load environment variables from the .env file, ensuring that COMPOSE_PROFILES is retrieved from the environment. - Updated the is_supabase_enabled() function to check for 'supabase' in the environment variable instead of directly from the .env file. - Improved the documentation to clarify the reliance on environment variables for service configuration. --- start_services.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/start_services.py b/start_services.py index db5fffd..92cdf7c 100755 --- a/start_services.py +++ b/start_services.py @@ -14,12 +14,12 @@ import time import argparse import platform import sys -from dotenv import dotenv_values +from dotenv import dotenv_values, load_dotenv def is_supabase_enabled(): - """Check if 'supabase' is in COMPOSE_PROFILES in .env file.""" - env_values = dotenv_values(".env") - compose_profiles = env_values.get("COMPOSE_PROFILES", "") + """Check if 'supabase' is in COMPOSE_PROFILES in the environment.""" + # Relies on load_dotenv() being called in main() + compose_profiles = os.environ.get("COMPOSE_PROFILES", "") return "supabase" in compose_profiles.split(',') def run_command(cmd, cwd=None): @@ -230,6 +230,8 @@ def check_and_fix_docker_compose_for_searxng(): print(f"Error checking/modifying docker-compose.yml for SearXNG: {e}") def main(): + load_dotenv(".env") # Load/Reload .env into os.environ + if is_supabase_enabled(): clone_supabase_repo() prepare_supabase_env()