Spaces:
Running
Running
chore: increase keepalive frequency to every minute and add logging for health check requests
Browse files- cloudflare-keepalive-setup.py +1 -1
- health-server.js +3 -0
cloudflare-keepalive-setup.py
CHANGED
|
@@ -155,7 +155,7 @@ def setup_keepalive_worker(api_token: str, account_id: str, subdomain: str) -> N
|
|
| 155 |
write_keepalive_status({"configured": False, "status": "skipped", "message": "SPACE_HOST could not be determined."})
|
| 156 |
return
|
| 157 |
|
| 158 |
-
cron = os.environ.get("CLOUDFLARE_KEEPALIVE_CRON", "*
|
| 159 |
space_host = space_host.removeprefix("https://").removeprefix("http://").split("/")[0]
|
| 160 |
target_url = os.environ.get("CLOUDFLARE_KEEPALIVE_URL", f"https://{space_host}/health").strip()
|
| 161 |
worker_name = derive_keepalive_worker_name()
|
|
|
|
| 155 |
write_keepalive_status({"configured": False, "status": "skipped", "message": "SPACE_HOST could not be determined."})
|
| 156 |
return
|
| 157 |
|
| 158 |
+
cron = os.environ.get("CLOUDFLARE_KEEPALIVE_CRON", "* * * * *").strip()
|
| 159 |
space_host = space_host.removeprefix("https://").removeprefix("http://").split("/")[0]
|
| 160 |
target_url = os.environ.get("CLOUDFLARE_KEEPALIVE_URL", f"https://{space_host}/health").strip()
|
| 161 |
worker_name = derive_keepalive_worker_name()
|
health-server.js
CHANGED
|
@@ -531,6 +531,9 @@ const server = http.createServer(async (req, res) => {
|
|
| 531 |
}
|
| 532 |
|
| 533 |
if (path === "/health" || path === `${APP_BASE}/health`) {
|
|
|
|
|
|
|
|
|
|
| 534 |
const data = await statusPayload();
|
| 535 |
res.writeHead(data.ok ? 200 : 503, { "content-type": "application/json" });
|
| 536 |
res.end(
|
|
|
|
| 531 |
}
|
| 532 |
|
| 533 |
if (path === "/health" || path === `${APP_BASE}/health`) {
|
| 534 |
+
if (req.headers["user-agent"] === "HuggingMess Cloudflare KeepAlive") {
|
| 535 |
+
console.log(`[${new Date().toISOString()}] Received keepalive ping from Cloudflare.`);
|
| 536 |
+
}
|
| 537 |
const data = await statusPayload();
|
| 538 |
res.writeHead(data.ok ? 200 : 503, { "content-type": "application/json" });
|
| 539 |
res.end(
|