chore: use healthcheck method in healthz
This commit is contained in:
parent
1b45b0917f
commit
de9a938da2
@ -1,26 +1,12 @@
|
||||
import { loadContext } from '~/utils/config/headplane';
|
||||
import { HeadscaleError, pull } from '~/utils/headscale';
|
||||
import { healthcheck } from '~/utils/headscale';
|
||||
import log from '~/utils/log';
|
||||
|
||||
export async function loader() {
|
||||
const context = await loadContext();
|
||||
const prefix = context.headscaleUrl;
|
||||
const health = new URL('health', prefix);
|
||||
log.debug('APIC', 'GET %s', health.toString());
|
||||
let healthy = false
|
||||
|
||||
let healthy = false;
|
||||
try {
|
||||
const res = await fetch(health.toString(), {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
healthy = true;
|
||||
}
|
||||
} catch (e) {
|
||||
log.debug('APIC', 'GET %s failed with error %s', health.toString(), e);
|
||||
healthy = await healthcheck();
|
||||
} catch (error) {
|
||||
log.debug('APIC', 'Healthcheck failed %o', error);
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({ status: healthy ? 'OK' : 'ERROR' }), {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user