Skip to content

Commit 5c26872

Browse files
committed
fix: adjust deployment config
1 parent ec77028 commit 5c26872

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

deploy/scripts/docker-entrypoint.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ echo "ProStaff API - Docker Entrypoint" >&2
66
echo "========================================" >&2
77

88
# Remove any pre-existing server PID file
9-
echo "[1/4] Removing stale PID files..." >&2
9+
echo "[1/5] Removing stale PID files..." >&2
1010
rm -f /app/tmp/pids/server.pid
1111

1212
# Wait for database to be ready
13-
echo "[2/4] Checking database connection..." >&2
13+
echo "[2/5] Checking database connection..." >&2
1414
DB_URL="${SUPABASE_DB_URL:-$DATABASE_URL}"
1515
if [ -n "$DB_URL" ]; then
1616
# Extract host and port from URL (format: postgresql://user:pass@host:port/db)
@@ -36,8 +36,28 @@ else
3636
echo " ⚠ No DATABASE_URL configured, skipping database check" >&2
3737
fi
3838

39+
# Check Redis connection (non-blocking)
40+
echo "[3/5] Checking Redis connection..." >&2
41+
if [ -n "$REDIS_URL" ]; then
42+
# Extract host and port from Redis URL
43+
REDIS_HOST=$(echo "$REDIS_URL" | sed -E 's|redis://([^:@]+:)?([^@:]+)(:([0-9]+))?.*|\2|')
44+
REDIS_PORT=$(echo "$REDIS_URL" | sed -E 's|.*:([0-9]+)(/[0-9]+)?$|\1|')
45+
46+
echo " → Redis: ${REDIS_HOST}:${REDIS_PORT}" >&2
47+
48+
# Try to connect to Redis (timeout after 5 seconds)
49+
if timeout 5 bash -c "echo > /dev/tcp/${REDIS_HOST}/${REDIS_PORT}" 2>/dev/null; then
50+
echo " ✓ Redis is reachable" >&2
51+
else
52+
echo " ⚠ Redis connection failed - Sidekiq will not work properly" >&2
53+
echo " → REDIS_URL: ${REDIS_URL}" >&2
54+
fi
55+
else
56+
echo " ⚠ No REDIS_URL configured, Sidekiq will run in inline mode" >&2
57+
fi
58+
3959
# Run database migrations
40-
echo "[3/4] Running database migrations..." >&2
60+
echo "[4/5] Running database migrations..." >&2
4161
if bundle exec rails db:migrate 2>&1 | tee /tmp/migration.log >&2; then
4262
echo " ✓ Migrations completed" >&2
4363
else
@@ -48,7 +68,7 @@ else
4868
fi
4969

5070
# Skip preload in production - Puma will handle it
51-
echo "[4/4] Starting application server..." >&2
71+
echo "[5/5] Starting application server..." >&2
5272
echo " → Port: ${PORT:-3000}" >&2
5373
echo " → Environment: ${RAILS_ENV:-development}" >&2
5474
echo " → Workers: ${WEB_CONCURRENCY:-2}" >&2

0 commit comments

Comments
 (0)