This commit is contained in:
@@ -54,17 +54,23 @@ jobs:
|
||||
echo "🟢 Starting Backend..."
|
||||
docker compose -f docker-compose-app.yml up -d backend
|
||||
|
||||
# 4b. รอ Backend healthy (ทุก 5 วิ สูงสุด 60 วิ)
|
||||
# 4b. รอ Backend healthy (ทุก 30 วิ สูงสุด 180 วิ)
|
||||
echo "⏳ Waiting for Backend health check..."
|
||||
for i in $(seq 1 12); do
|
||||
if docker inspect --format='{{.State.Health.Status}}' backend 2>/dev/null | grep -q healthy; then
|
||||
for i in $(seq 1 6); do
|
||||
echo "🔍 Health check attempt $i/6..."
|
||||
health=$(docker inspect --format='{{.State.Health.Status}}' backend 2>/dev/null || echo "starting")
|
||||
echo "📊 Health status: $health"
|
||||
if [ "$health" = "healthy" ]; then
|
||||
echo "✅ Backend is healthy!"
|
||||
break
|
||||
fi
|
||||
if [ "$i" = "12" ]; then
|
||||
echo "⚠️ Backend health check timeout - starting frontend anyway"
|
||||
if [ "$i" = "6" ]; then
|
||||
echo "⚠️ Backend health check timeout after 180s - checking logs"
|
||||
echo "📋 Backend logs (last 20 lines):"
|
||||
docker logs --tail 20 backend
|
||||
echo "🔧 Starting frontend anyway (backend may still be starting)"
|
||||
fi
|
||||
sleep 5
|
||||
sleep 30
|
||||
done
|
||||
|
||||
# 4c. Start Frontend
|
||||
|
||||
+1
-1
@@ -77,6 +77,6 @@ USER nestjs
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=30s \
|
||||
CMD curl -f http://localhost:3000/health || exit 1
|
||||
CMD curl -f http://localhost:3000/ping || exit 1
|
||||
|
||||
CMD ["node", "dist/main"]
|
||||
|
||||
@@ -19,6 +19,11 @@ export class HealthController {
|
||||
private disk: DiskHealthIndicator
|
||||
) {}
|
||||
|
||||
@Get('ping')
|
||||
ping() {
|
||||
return { status: 'ok', timestamp: new Date().toISOString() };
|
||||
}
|
||||
|
||||
@Get('health')
|
||||
@HealthCheck()
|
||||
check() {
|
||||
|
||||
Reference in New Issue
Block a user