headplane/app/routes/util/healthz.ts

19 lines
430 B
TypeScript
Raw Normal View History

import { healthcheck } from '~/utils/headscale';
import log from '~server/utils/log';
2024-11-27 11:23:42 -05:00
export async function loader() {
let healthy = false;
2024-11-27 11:23:42 -05:00
try {
healthy = await healthcheck();
} catch (error) {
log.debug('APIC', 'Healthcheck failed %o', error);
2024-11-27 11:23:42 -05:00
}
return new Response(JSON.stringify({ status: healthy ? 'OK' : 'ERROR' }), {
status: healthy ? 200 : 500,
headers: {
'Content-Type': 'application/json',
},
});
2024-11-27 11:23:42 -05:00
}