Fix nginx error log and debug Redis URL format
This commit is contained in:
@@ -25,6 +25,9 @@ COPY start.sh /app/code/
|
||||
COPY healthcheck.js /app/code/
|
||||
COPY nginx.conf /etc/nginx/sites-available/default
|
||||
|
||||
# Override nginx global error log to prevent read-only filesystem error
|
||||
RUN sed -i 's|error_log /var/log/nginx/error.log;|error_log /dev/stderr;|' /etc/nginx/nginx.conf
|
||||
|
||||
# Make scripts executable
|
||||
RUN chmod +x /app/code/start.sh /app/code/healthcheck.js
|
||||
|
||||
|
27
start.sh
27
start.sh
@@ -38,9 +38,14 @@ echo "=> Configuring Redis..."
|
||||
# The CLOUDRON_REDIS_URL is in format: redis://:password@host:port
|
||||
# We need to ensure it's in the correct format for ioredis
|
||||
|
||||
# Debug: Print the original Redis URL
|
||||
echo "=> Original CLOUDRON_REDIS_URL: ${CLOUDRON_REDIS_URL}"
|
||||
|
||||
if [ -n "${CLOUDRON_REDIS_URL}" ]; then
|
||||
# Extract components from the URL
|
||||
# Format: redis://:password@host:port/database
|
||||
# Try to use the original URL first and see if it's valid
|
||||
export REDIS_URL="${CLOUDRON_REDIS_URL}"
|
||||
|
||||
# Also extract components for individual env vars
|
||||
REDIS_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://:\([^@]*\)@.*|\1|p')
|
||||
REDIS_HOST=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@\([^:]*\):.*|\1|p')
|
||||
REDIS_PORT=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@[^:]*:\([0-9]*\).*|\1|p')
|
||||
@@ -54,20 +59,18 @@ if [ -n "${CLOUDRON_REDIS_URL}" ]; then
|
||||
export REDIS_HOST="${REDIS_HOST}"
|
||||
export REDIS_PORT="${REDIS_PORT}"
|
||||
export REDIS_PASSWORD="${REDIS_PASSWORD}"
|
||||
|
||||
# Also export the full URL in case it's needed - try different formats
|
||||
export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}"
|
||||
export REDIS_DB="0"
|
||||
|
||||
echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}"
|
||||
echo "=> Final Redis URL: ${REDIS_URL}"
|
||||
echo "=> Using Redis URL: ${REDIS_URL}"
|
||||
|
||||
# Try alternative formats if the original fails
|
||||
if [ -z "$REDIS_PASSWORD" ]; then
|
||||
export REDIS_URL="redis://${REDIS_HOST}:${REDIS_PORT}"
|
||||
fi
|
||||
else
|
||||
echo "=> Warning: Redis URL not provided"
|
||||
# Set dummy Redis URL to prevent validation errors
|
||||
export REDIS_URL="redis://localhost:6379"
|
||||
export REDIS_HOST="localhost"
|
||||
export REDIS_PORT="6379"
|
||||
export REDIS_PASSWORD=""
|
||||
echo "=> Error: Redis URL not provided by Cloudron"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Email configuration
|
||||
|
Reference in New Issue
Block a user