Refactor Supabase compose file handling in start_services.py

- Updated the stop_existing_containers function to conditionally include the Supabase compose file only if Supabase is enabled, improving clarity and functionality.
- Added logging to inform users about the presence or absence of the Supabase compose file, enhancing the shutdown process.
- Included checks for the existence of the Supabase compose file to provide context when Supabase is disabled, ensuring better user feedback.
This commit is contained in:
Yury Kossakovsky
2025-05-22 13:46:02 -06:00
parent f11b303531
commit 5351443f76

View File

@@ -65,13 +65,25 @@ def stop_existing_containers():
compose_files_args = ["-f", "docker-compose.yml"]
supabase_docker_dir = os.path.join("supabase", "docker")
supabase_compose_file = os.path.join(supabase_docker_dir, "docker-compose.yml")
if os.path.exists(supabase_compose_file):
print(f"Supabase compose file found at {supabase_compose_file}, adding to commands.")
compose_files_args.extend(["-f", supabase_compose_file])
# Only include Supabase compose file if Supabase is enabled
if is_supabase_enabled():
supabase_docker_dir = os.path.join("supabase", "docker")
supabase_compose_file = os.path.join(supabase_docker_dir, "docker-compose.yml")
if os.path.exists(supabase_compose_file):
print(f"Supabase is enabled and compose file found at {supabase_compose_file}, adding to commands.")
compose_files_args.extend(["-f", supabase_compose_file])
else:
# This case should ideally not happen if Supabase is enabled and cloned properly
print(f"Supabase is enabled but its compose file was not found at {supabase_compose_file}.")
else:
print(f"Supabase compose file not found at {supabase_compose_file}.")
# If Supabase is not enabled, we don't include its compose file.
# Lingering Supabase containers will be handled by force_stop_lingering_containers()
print("Supabase is not enabled, its compose file will not be used for stop/rm Docker Compose commands.")
# We also check if the Supabase compose file path exists to provide more context,
# as it might exist from a previous run where Supabase was enabled.
supabase_compose_file_if_exists = os.path.join("supabase", "docker", "docker-compose.yml")
if os.path.exists(supabase_compose_file_if_exists):
print(f"Note: Supabase compose file exists at {supabase_compose_file_if_exists} but is not being used as Supabase is disabled.")
base_cmd_prefix = ["docker", "compose", "-p", "localai"] + compose_files_args