fix: add pylon relay fallback to dashboard status endpoint
The dashboard uses /api/v1/services/status (not /api/health/services) for live status cards. This endpoint was missing pylon relay fallback, so services unreachable from the Docker container showed as OFF even when the pylon was running. Also adds Windows VBS startup wrapper for pylon persistence across reboots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2
dashcaddy-api/pylon/start-pylon.vbs
Normal file
2
dashcaddy-api/pylon/start-pylon.vbs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Set WshShell = CreateObject("WScript.Shell")
|
||||||
|
WshShell.Run """C:\Program Files\nodejs\node.exe"" ""E:\CaddyCerts\sites\dashcaddy-api\pylon\dashcaddy-pylon.js""", 0, False
|
||||||
@@ -65,6 +65,25 @@ module.exports = function(ctx) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function probeViaPylon(targetUrl) {
|
||||||
|
const pylonConfig = ctx.siteConfig?.pylon;
|
||||||
|
if (!pylonConfig?.url) return null;
|
||||||
|
try {
|
||||||
|
const probeUrl = `${pylonConfig.url}/probe?url=${encodeURIComponent(targetUrl)}`;
|
||||||
|
const headers = {};
|
||||||
|
if (pylonConfig.key) headers['x-pylon-key'] = pylonConfig.key;
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timeout = setTimeout(() => controller.abort(), 12000);
|
||||||
|
const response = await ctx.fetchT(probeUrl, { method: 'GET', signal: controller.signal, headers });
|
||||||
|
clearTimeout(timeout);
|
||||||
|
if (!response.ok) return null;
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function probeServiceStatus(id, service) {
|
async function probeServiceStatus(id, service) {
|
||||||
const startedAt = process.hrtime.bigint();
|
const startedAt = process.hrtime.bigint();
|
||||||
let url = resolveProbeUrl(id, service);
|
let url = resolveProbeUrl(id, service);
|
||||||
@@ -92,6 +111,22 @@ module.exports = function(ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pylon relay fallback — if direct probes failed, try through the pylon
|
||||||
|
if (error && ctx.siteConfig?.pylon) {
|
||||||
|
const pylonResult = await probeViaPylon(url);
|
||||||
|
if (pylonResult && pylonResult.status) {
|
||||||
|
const responseTime = Number((process.hrtime.bigint() - startedAt) / 1000000n);
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
isUp: pylonResult.status === 'healthy',
|
||||||
|
statusCode: pylonResult.statusCode || 0,
|
||||||
|
responseTime,
|
||||||
|
url,
|
||||||
|
via: 'pylon'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const responseTime = Number((process.hrtime.bigint() - startedAt) / 1000000n);
|
const responseTime = Number((process.hrtime.bigint() - startedAt) / 1000000n);
|
||||||
if (error) {
|
if (error) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user