diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 0e3513f0..3d99a18f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -183,32 +183,12 @@ 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) +# Launch uwsgi with configurable nice level (default: 0 for normal 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 # This preserves both the nice value and environment variables -cd /app && nice -n $UWSGI_NICE_LEVEL setpriv --reuid=$POSTGRES_USER --regid=$POSTGRES_USER --clear-groups -- uwsgi $uwsgi_args & +# Use --keep-groups instead of --clear-groups for LXC compatibility with attach-daemons +cd /app && nice -n $UWSGI_NICE_LEVEL setpriv --reuid=$POSTGRES_USER --regid=$POSTGRES_USER --keep-groups -- uwsgi $uwsgi_args & uwsgi_pid=$! echo "✅ uwsgi started with PID $uwsgi_pid (nice $UWSGI_NICE_LEVEL)" pids+=("$uwsgi_pid") diff --git a/docker/uwsgi.debug.ini b/docker/uwsgi.debug.ini index 785d3218..3de890a5 100644 --- a/docker/uwsgi.debug.ini +++ b/docker/uwsgi.debug.ini @@ -2,8 +2,12 @@ ; exec-before = python manage.py collectstatic --noinput ; exec-before = python manage.py migrate --noinput -; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions -; Start services with configurable nice level (default: 5 for low priority) +; 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) ; 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 diff --git a/docker/uwsgi.dev.ini b/docker/uwsgi.dev.ini index f6681969..e476e216 100644 --- a/docker/uwsgi.dev.ini +++ b/docker/uwsgi.dev.ini @@ -4,8 +4,12 @@ ; exec-pre = touch /data/logs/uwsgi-dev.log ; exec-pre = chmod 666 /data/logs/uwsgi-dev.log -; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions -; Start services with configurable nice level (default: 5 for low priority) +; 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) ; 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 diff --git a/docker/uwsgi.ini b/docker/uwsgi.ini index 9d0ab9bc..f8fe8ab7 100644 --- a/docker/uwsgi.ini +++ b/docker/uwsgi.ini @@ -4,8 +4,12 @@ ; exec-pre = touch /data/logs/uwsgi.log ; exec-pre = chmod 666 /data/logs/uwsgi.log -; Redis is now started in entrypoint.sh before uwsgi to prevent race conditions -; Start services with configurable nice level (default: 5 for low priority) +; 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) ; 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