feat: add health check route
This commit is contained in:
parent
b433e607e2
commit
a7d127c7bf
29
app/routes/healthz.tsx
Normal file
29
app/routes/healthz.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { loadContext } from '~/utils/config/headplane'
|
||||||
|
import { HeadscaleError, pull } from '~/utils/headscale'
|
||||||
|
import log from '~/utils/log'
|
||||||
|
|
||||||
|
export async function loader() {
|
||||||
|
const context = await loadContext()
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Doesn't matter, we just need a 401
|
||||||
|
await pull('v1/', 'wrongkey')
|
||||||
|
} catch (e) {
|
||||||
|
if (!(e instanceof HeadscaleError)) {
|
||||||
|
log.debug('Healthz', 'Headscale is not reachable')
|
||||||
|
return new Response('Headscale is not reachable', {
|
||||||
|
status: 500,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response('OK', {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user