This commit is contained in:
@@ -54,17 +54,23 @@ jobs:
|
|||||||
echo "🟢 Starting Backend..."
|
echo "🟢 Starting Backend..."
|
||||||
docker compose -f docker-compose-app.yml up -d 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..."
|
echo "⏳ Waiting for Backend health check..."
|
||||||
for i in $(seq 1 12); do
|
for i in $(seq 1 6); do
|
||||||
if docker inspect --format='{{.State.Health.Status}}' backend 2>/dev/null | grep -q healthy; then
|
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!"
|
echo "✅ Backend is healthy!"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [ "$i" = "12" ]; then
|
if [ "$i" = "6" ]; then
|
||||||
echo "⚠️ Backend health check timeout - starting frontend anyway"
|
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
|
fi
|
||||||
sleep 5
|
sleep 30
|
||||||
done
|
done
|
||||||
|
|
||||||
# 4c. Start Frontend
|
# 4c. Start Frontend
|
||||||
|
|||||||
+1
-1
@@ -77,6 +77,6 @@ USER nestjs
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=30s \
|
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"]
|
CMD ["node", "dist/main"]
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ export class HealthController {
|
|||||||
private disk: DiskHealthIndicator
|
private disk: DiskHealthIndicator
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@Get('ping')
|
||||||
|
ping() {
|
||||||
|
return { status: 'ok', timestamp: new Date().toISOString() };
|
||||||
|
}
|
||||||
|
|
||||||
@Get('health')
|
@Get('health')
|
||||||
@HealthCheck()
|
@HealthCheck()
|
||||||
check() {
|
check() {
|
||||||
|
|||||||
Reference in New Issue
Block a user