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 healthcheck.js /app/code/
|
||||||
COPY nginx.conf /etc/nginx/sites-available/default
|
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
|
# Make scripts executable
|
||||||
RUN chmod +x /app/code/start.sh /app/code/healthcheck.js
|
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
|
# The CLOUDRON_REDIS_URL is in format: redis://:password@host:port
|
||||||
# We need to ensure it's in the correct format for ioredis
|
# 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
|
if [ -n "${CLOUDRON_REDIS_URL}" ]; then
|
||||||
# Extract components from the URL
|
# Try to use the original URL first and see if it's valid
|
||||||
# Format: redis://:password@host:port/database
|
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_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://:\([^@]*\)@.*|\1|p')
|
||||||
REDIS_HOST=$(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')
|
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_HOST="${REDIS_HOST}"
|
||||||
export REDIS_PORT="${REDIS_PORT}"
|
export REDIS_PORT="${REDIS_PORT}"
|
||||||
export REDIS_PASSWORD="${REDIS_PASSWORD}"
|
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"
|
export REDIS_DB="0"
|
||||||
|
|
||||||
echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}"
|
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
|
else
|
||||||
echo "=> Warning: Redis URL not provided"
|
echo "=> Error: Redis URL not provided by Cloudron"
|
||||||
# Set dummy Redis URL to prevent validation errors
|
exit 1
|
||||||
export REDIS_URL="redis://localhost:6379"
|
|
||||||
export REDIS_HOST="localhost"
|
|
||||||
export REDIS_PORT="6379"
|
|
||||||
export REDIS_PASSWORD=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Email configuration
|
# Email configuration
|
||||||
|
Reference in New Issue
Block a user