@@ -14,11 +14,17 @@ trap "kill $rails_pid 2>/dev/null || true" EXIT
1414
1515# Wait for Rails server to be ready with retry logic
1616echo " Waiting for Rails server to start..."
17- max_attempts=30
17+ max_attempts=60
1818attempt=0
1919while [ $attempt -lt $max_attempts ]; do
20- if curl -f -s http://localhost:3000/resources? category_id=1 > /dev/null 2>&1 ; then
21- echo " Rails server is ready!"
20+ # Check if server responds with any HTTP status (even errors mean server is up)
21+ http_code=$( curl -s -o /dev/null -w " %{http_code}" --max-time 2 http://localhost:3000/ 2> /dev/null || echo " 000" )
22+
23+ # Any HTTP response code (200, 404, 500, etc.) means server is responding
24+ if [ " $http_code " != " 000" ] && [ " $http_code " != " " ]; then
25+ echo " Rails server is ready! (HTTP $http_code )"
26+ # Give it a moment to fully initialize
27+ sleep 2
2228 break
2329 fi
2430
@@ -30,13 +36,19 @@ while [ $attempt -lt $max_attempts ]; do
3036 fi
3137
3238 attempt=$(( attempt + 1 ))
33- echo " Server not ready yet, waiting... (attempt $attempt /$max_attempts )"
34- sleep 2
39+ if [ $(( attempt % 5 )) -eq 0 ]; then
40+ echo " Server not ready yet, waiting... (attempt $attempt /$max_attempts , last HTTP code: $http_code )"
41+ fi
42+ sleep 1
3543done
3644
3745if [ $attempt -eq $max_attempts ]; then
3846 echo " ERROR: Rails server did not become ready after $max_attempts attempts"
39- echo " Checking server logs..."
47+ echo " Last HTTP response code: $http_code "
48+ echo " Testing connection..."
49+ curl -v --max-time 5 http://localhost:3000/ 2>&1 | head -30 || true
50+ echo " Checking server process..."
51+ ps aux | grep rails || true
4052 kill $rails_pid 2> /dev/null || true
4153 wait $rails_pid || true
4254 exit 1
0 commit comments