mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
feat: Get the health checks for the js
This commit is contained in:
@@ -47,10 +47,10 @@ export function healthCheck(o: {
|
||||
} catch (e) {
|
||||
await o.effects.setHealth({
|
||||
name: o.name,
|
||||
status: "failing",
|
||||
status: "failure",
|
||||
message: asMessage(e),
|
||||
})
|
||||
currentValue.lastResult = "failing"
|
||||
currentValue.lastResult = "failure"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function checkPortListening(
|
||||
return { status: "passing", message: options.successMessage }
|
||||
}
|
||||
return {
|
||||
status: "failing",
|
||||
status: "failure",
|
||||
message: options.errorMessage,
|
||||
}
|
||||
}),
|
||||
@@ -56,7 +56,7 @@ export async function checkPortListening(
|
||||
setTimeout(
|
||||
() =>
|
||||
resolve({
|
||||
status: "failing",
|
||||
status: "failure",
|
||||
message:
|
||||
options.timeoutMessage || `Timeout trying to check port ${port}`,
|
||||
}),
|
||||
|
||||
@@ -19,14 +19,17 @@ export const checkWebUrl = async (
|
||||
} = {},
|
||||
): Promise<CheckResult> => {
|
||||
return Promise.race([fetch(url), timeoutPromise(timeout)])
|
||||
.then((x) => ({
|
||||
status: "passing" as const,
|
||||
message: successMessage,
|
||||
}))
|
||||
.then(
|
||||
(x) =>
|
||||
({
|
||||
status: "passing",
|
||||
message: successMessage,
|
||||
}) as const,
|
||||
)
|
||||
.catch((e) => {
|
||||
console.warn(`Error while fetching URL: ${url}`)
|
||||
console.error(JSON.stringify(e))
|
||||
console.error(e.toString())
|
||||
return { status: "failing" as const, message: errorMessage }
|
||||
return { status: "failure" as const, message: errorMessage }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export const runHealthScript = async (
|
||||
console.warn(errorMessage)
|
||||
console.warn(JSON.stringify(e))
|
||||
console.warn(e.toString())
|
||||
throw { status: "failing", message: errorMessage } as CheckResult
|
||||
throw { status: "failure", message: errorMessage } as CheckResult
|
||||
})
|
||||
return {
|
||||
status: "passing",
|
||||
|
||||
@@ -121,7 +121,7 @@ export class Daemons<Manifest extends SDKManifest, Ids extends string> {
|
||||
const response = await Promise.resolve(daemon.ready.fn()).catch(
|
||||
(err) =>
|
||||
({
|
||||
status: "failing",
|
||||
status: "failure",
|
||||
message: "message" in err ? err.message : String(err),
|
||||
}) as CheckResult,
|
||||
)
|
||||
|
||||
@@ -133,7 +133,12 @@ export type Daemon = {
|
||||
[DaemonProof]: never
|
||||
}
|
||||
|
||||
export type HealthStatus = "passing" | "warning" | "failing" | "disabled"
|
||||
export type HealthStatus =
|
||||
| `passing`
|
||||
| `disabled`
|
||||
| `starting`
|
||||
| `warning`
|
||||
| `failure`
|
||||
|
||||
export type SmtpValue = {
|
||||
server: string
|
||||
|
||||
Reference in New Issue
Block a user