fix: read Redis URL from environment variables for Docker deployment (fixes #385)#469
Open
octo-patch wants to merge 1 commit intoFosowl:mainfrom
Open
fix: read Redis URL from environment variables for Docker deployment (fixes #385)#469octo-patch wants to merge 1 commit intoFosowl:mainfrom
octo-patch wants to merge 1 commit intoFosowl:mainfrom
Conversation
…ixes Fosowl#385) Celery broker and backend URLs were hardcoded to redis://localhost:6379/0, which prevents connection to the Redis container in Docker deployments. The docker-compose.yml already passes REDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0} to the backend container, but the code was ignoring it. Now reads REDIS_URL first (set by docker-compose), falls back to REDIS_BASE_URL (user-facing env var name in .env.example), then falls back to localhost for non-Docker development use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #385
Problem
The Celery broker and backend URLs were hardcoded to
redis://localhost:6379/0inapi.py:When running in Docker, the Redis service is reachable at
redis://redis:6379/0(via the Docker network using the service name), notlocalhost. Thedocker-compose.ymlalready correctly passesREDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0}as an environment variable to the backend container, but the code was ignoring it entirely.This causes the backend container to silently fail to connect to Redis during startup, resulting in the symptom reported in #385: the container shows
Device set to use cpuand then never reaches the Uvicorn startup logs.Solution
Read the Redis URL from environment variables before falling back to
localhost:REDIS_URL— set bydocker-compose.ymlfor Docker deploymentsREDIS_BASE_URL— the user-facing variable name documented in.env.exampleredis://localhost:6379/0— fallback for local (non-Docker) developmentTesting
localhost)REDIS_URL=redis://redis:6379/0is picked up from the environment, matching the existingdocker-compose.ymlconfiguration