Testing redis potential fix. Launch redis in entrypoint before uWSGI

This commit is contained in:
SergeantPanda 2025-10-21 21:47:15 -05:00
parent dd5f0d0753
commit 645c1ec9df
4 changed files with 27 additions and 18 deletions

View file

@ -183,6 +183,27 @@ if [ "$DISPATCHARR_DEBUG" != "true" ]; then
uwsgi_args+=" --disable-logging"
fi
# Start Redis before uwsgi to ensure it's available when Django apps initialize
echo "🚀 Starting Redis..."
setpriv --reuid=$POSTGRES_USER --regid=$POSTGRES_USER --clear-groups -- redis-server --daemonize yes
# Wait for Redis to be ready
echo "⏳ Waiting for Redis to be ready..."
python /app/scripts/wait_for_redis.py
if [ $? -ne 0 ]; then
echo "❌ Redis failed to start properly!"
exit 1
fi
redis_pid=$(pgrep -x redis-server)
if [ -n "$redis_pid" ]; then
echo "✅ Redis started with PID $redis_pid"
pids+=("$redis_pid")
else
echo "❌ Redis process not found after startup!"
exit 1
fi
# Launch uwsgi with configurable nice level (default: -10 for high priority)
# Users can override via UWSGI_NICE_LEVEL environment variable in docker-compose
# Start with nice as root, then use setpriv to drop privileges to dispatch user

View file

@ -2,12 +2,8 @@
; exec-before = python manage.py collectstatic --noinput
; exec-before = python manage.py migrate --noinput
; First run Redis availability check script once
exec-before = python /app/scripts/wait_for_redis.py
; Start Redis first
attach-daemon = redis-server
; Then start other services with configurable nice level (default: 5 for low priority)
; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions
; Start services with configurable nice level (default: 5 for low priority)
; Users can override via CELERY_NICE_LEVEL environment variable in docker-compose
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr worker --autoscale=6,1
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr beat

View file

@ -4,12 +4,8 @@
; exec-pre = touch /data/logs/uwsgi-dev.log
; exec-pre = chmod 666 /data/logs/uwsgi-dev.log
; First run Redis availability check script once
exec-pre = python /app/scripts/wait_for_redis.py
; Start Redis first
attach-daemon = redis-server
; Then start other services with configurable nice level (default: 5 for low priority)
; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions
; Start services with configurable nice level (default: 5 for low priority)
; Users can override via CELERY_NICE_LEVEL environment variable in docker-compose
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr worker --autoscale=6,1
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr beat

View file

@ -4,12 +4,8 @@
; exec-pre = touch /data/logs/uwsgi.log
; exec-pre = chmod 666 /data/logs/uwsgi.log
; First run Redis availability check script once
exec-pre = python /app/scripts/wait_for_redis.py
; Start Redis first
attach-daemon = redis-server
; Then start other services with configurable nice level (default: 5 for low priority)
; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions
; Start services with configurable nice level (default: 5 for low priority)
; Users can override via CELERY_NICE_LEVEL environment variable in docker-compose
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr worker --autoscale=6,1
attach-daemon = nice -n $(CELERY_NICE_LEVEL) celery -A dispatcharr beat