Move Dockerfile to repository root for Ghaymah build
هذا الالتزام موجود في:
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM python:3.10-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir fastapi uvicorn requests
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
24
app.py
Normal file
24
app.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
import time
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
start_time = time.time()
|
||||||
|
request_count = 0
|
||||||
|
|
||||||
|
@app.middleware("http")
|
||||||
|
def count_requests(request, call_next):
|
||||||
|
global request_count
|
||||||
|
request_count += 1
|
||||||
|
return call_next(request)
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def root():
|
||||||
|
return {"message": "Welcome to Ghaymah SRE Service"}
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return {
|
||||||
|
"status": "healthy",
|
||||||
|
"uptime_seconds": round(time.time() - start_time, 2),
|
||||||
|
"total_requests": request_count
|
||||||
|
}
|
||||||
48
dashboard.html
Normal file
48
dashboard.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ar" dir="rtl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Ghaymah App Dashboard</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 30px; }
|
||||||
|
.grid { display: flex; gap: 20px; margin-top: 20px; }
|
||||||
|
.card { background: #1e293b; padding: 25px; border-radius: 10px; flex: 1; text-align: center; border: 1px solid #334155; }
|
||||||
|
.status-up { color: #22c55e; }
|
||||||
|
.status-down { color: #ef4444; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>🚀 لوحة مراقبة التطبيق - Ghaymah Cloud</h2>
|
||||||
|
<div class="grid">
|
||||||
|
<div class="card">
|
||||||
|
<h3>الحالة (Status)</h3>
|
||||||
|
<h1 id="status" class="status-up">--</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>زمن الاستجابة (Latency)</h3>
|
||||||
|
<h1><span id="latency">0</span> ثانية</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>إجمالي الطلبات (Total Requests)</h3>
|
||||||
|
<h1 id="requests">0</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function updateDashboard() {
|
||||||
|
try {
|
||||||
|
const res = await fetch('metrics.json');
|
||||||
|
const data = await res.json();
|
||||||
|
document.getElementById('status').innerText = data.status === "200" ? "UP (200 OK)" : "DOWN (" + data.status + ")";
|
||||||
|
document.getElementById('status').className = data.status === "200" ? "status-up" : "status-down";
|
||||||
|
document.getElementById('latency').innerText = data.latency;
|
||||||
|
document.getElementById('requests').innerText = data.total_requests;
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Waiting for metrics data...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setInterval(updateDashboard, 5000);
|
||||||
|
updateDashboard();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
25
health-check.sh
Executable file
25
health-check.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# استبدل هذا الرابط بالرابط العام المستلم من غيمة
|
||||||
|
TARGET_URL="https://q1-app.deploy.ghaymah.systems/health"
|
||||||
|
|
||||||
|
echo "Starting Monitoring for $TARGET_URL..."
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
# جلب الاستجابة وحساب الوقت
|
||||||
|
RESPONSE=$(curl -s "$TARGET_URL")
|
||||||
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$TARGET_URL")
|
||||||
|
RESPONSE_TIME=$(curl -s -w "%{time_total}" -o /dev/null "$TARGET_URL")
|
||||||
|
|
||||||
|
# استخراج عدد الطلبات من الـ Endpoint
|
||||||
|
TOTAL_REQUESTS=$(echo "$RESPONSE" | grep -o '"total_requests":[0-9]*' | grep -o '[0-9]*')
|
||||||
|
|
||||||
|
echo "[$TIMESTAMP] Status: $HTTP_STATUS | Latency: ${RESPONSE_TIME}s | Requests: ${TOTAL_REQUESTS:-0}"
|
||||||
|
|
||||||
|
# تحديث ملف المتركس للداشبورد
|
||||||
|
echo "{\"timestamp\": \"$TIMESTAMP\", \"status\": \"$HTTP_STATUS\", \"latency\": $RESPONSE_TIME, \"total_requests\": ${TOTAL_REQUESTS:-0}}" > metrics.json
|
||||||
|
|
||||||
|
sleep 30
|
||||||
|
done
|
||||||
1
metrics.json
Normal file
1
metrics.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"timestamp": "2026-07-26T11:28:46Z", "status": "200", "latency": 0.004614}
|
||||||
المرجع في مشكلة جديدة
حظر مستخدم