Skip to content

Commit a3bdfdd

Browse files
committed
make redis server configurable through $REDIS_URL
1 parent a8d3031 commit a3bdfdd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

backend/beets_flask/redis.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import asyncio
2+
import os
23
import time
34
from concurrent.futures import ThreadPoolExecutor
45

5-
from redis import Redis
6+
import redis
67
from rq import Queue
78
from rq.job import Job
89

910
# Setup redis connection
10-
redis_conn = Redis()
11+
if os.environ.get("REDIS_URL"):
12+
redis_conn = redis.from_url(os.environ["REDIS_URL"])
13+
else:
14+
redis_conn = redis.Redis()
1115

1216
# Init our different queues
1317
preview_queue = Queue("preview", connection=redis_conn, default_timeout=600)

docker/entrypoints/entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export PYTHONWARNINGS="ignore"
2121
# running the server from inside the backend dir makes imports and redis easier
2222
cd /repo/backend
2323

24-
redis-server --daemonize yes >/dev/null 2>&1
24+
if [ -z "$REDIS_URL" ]; then
25+
redis-server --daemonize yes >/dev/null 2>&1
26+
fi
2527

2628
# blocking
2729
python ./launch_db_init.py

0 commit comments

Comments
 (0)