Spaces:
Running
Running
feat: add /app/debug-logs endpoint to expose backend logs and proxy environment variables
Browse files- health-server.js +24 -0
health-server.js
CHANGED
|
@@ -1063,6 +1063,30 @@ const server = http.createServer((req, res) => {
|
|
| 1063 |
return;
|
| 1064 |
}
|
| 1065 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
// ββ Dashboard at exact / βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1067 |
if (pathname === "/" || pathname === "") {
|
| 1068 |
void (async () => {
|
|
|
|
| 1063 |
return;
|
| 1064 |
}
|
| 1065 |
|
| 1066 |
+
// ββ /app/debug-logs β Temporary endpoint for debugging βββββββββββββββββββ
|
| 1067 |
+
if (pathname === "/app/debug-logs") {
|
| 1068 |
+
try {
|
| 1069 |
+
const errLog = fs.existsSync("/root/.pm2/logs/backend-error.log")
|
| 1070 |
+
? fs.readFileSync("/root/.pm2/logs/backend-error.log", "utf8")
|
| 1071 |
+
: "No backend-error.log found";
|
| 1072 |
+
const outLog = fs.existsSync("/root/.pm2/logs/backend-out.log")
|
| 1073 |
+
? fs.readFileSync("/root/.pm2/logs/backend-out.log", "utf8")
|
| 1074 |
+
: "No backend-out.log found";
|
| 1075 |
+
|
| 1076 |
+
const cfProxyLog = fs.existsSync("/tmp/huggingpost-cloudflare-proxy.env")
|
| 1077 |
+
? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8")
|
| 1078 |
+
: "No proxy env";
|
| 1079 |
+
|
| 1080 |
+
const out = `=== BACKEND ERROR LOG ===\n${errLog}\n\n=== BACKEND OUT LOG ===\n${outLog}\n\n=== PROXY ENV ===\n${cfProxyLog}`;
|
| 1081 |
+
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
| 1082 |
+
res.end(out);
|
| 1083 |
+
} catch (e) {
|
| 1084 |
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
| 1085 |
+
res.end("Error reading logs: " + e.message);
|
| 1086 |
+
}
|
| 1087 |
+
return;
|
| 1088 |
+
}
|
| 1089 |
+
|
| 1090 |
// ββ Dashboard at exact / βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1091 |
if (pathname === "/" || pathname === "") {
|
| 1092 |
void (async () => {
|