mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
chore: Add in the possibility to get the status code from the executed health check
This commit is contained in:
@@ -73,6 +73,15 @@ export class DockerProcedureContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async execSpawn(commands: string[]) {
|
||||||
|
try {
|
||||||
|
const spawned = await this.overlay.spawn(commands)
|
||||||
|
return spawned
|
||||||
|
} finally {
|
||||||
|
await this.overlay.destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async spawn(commands: string[]): Promise<cp.ChildProcessWithoutNullStreams> {
|
async spawn(commands: string[]): Promise<cp.ChildProcessWithoutNullStreams> {
|
||||||
return await this.overlay.spawn(commands)
|
return await this.overlay.spawn(commands)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { DockerProcedureContainer } from "./DockerProcedureContainer"
|
|||||||
import { SystemForEmbassy } from "."
|
import { SystemForEmbassy } from "."
|
||||||
import { HostSystemStartOs } from "../../HostSystemStartOs"
|
import { HostSystemStartOs } from "../../HostSystemStartOs"
|
||||||
import { util, Daemons, types as T } from "@start9labs/start-sdk"
|
import { util, Daemons, types as T } from "@start9labs/start-sdk"
|
||||||
|
import { exec } from "child_process"
|
||||||
|
|
||||||
const EMBASSY_HEALTH_INTERVAL = 15 * 1000
|
const EMBASSY_HEALTH_INTERVAL = 15 * 1000
|
||||||
const EMBASSY_PROPERTIES_LOOP = 30 * 1000
|
const EMBASSY_PROPERTIES_LOOP = 30 * 1000
|
||||||
@@ -117,17 +118,54 @@ export class MainLoop {
|
|||||||
actionProcedure,
|
actionProcedure,
|
||||||
manifest.volumes,
|
manifest.volumes,
|
||||||
)
|
)
|
||||||
const executed = await container.exec([
|
const executed = await container.execSpawn([
|
||||||
actionProcedure.entrypoint,
|
actionProcedure.entrypoint,
|
||||||
...actionProcedure.args,
|
...actionProcedure.args,
|
||||||
JSON.stringify(timeChanged),
|
JSON.stringify(timeChanged),
|
||||||
])
|
])
|
||||||
const stderr = executed.stderr.toString()
|
if (executed.exitCode === 59) {
|
||||||
if (stderr)
|
await effects.setHealth({
|
||||||
console.error(
|
name: healthId,
|
||||||
`Error running health check ${value.name}: ${stderr}`,
|
status: "disabled",
|
||||||
)
|
message:
|
||||||
return executed.stdout.toString()
|
executed.stderr.toString() || executed.stdout.toString(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (executed.exitCode === 60) {
|
||||||
|
await effects.setHealth({
|
||||||
|
name: healthId,
|
||||||
|
status: "starting",
|
||||||
|
message:
|
||||||
|
executed.stderr.toString() || executed.stdout.toString(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (executed.exitCode === 61) {
|
||||||
|
await effects.setHealth({
|
||||||
|
name: healthId,
|
||||||
|
status: "warning",
|
||||||
|
message:
|
||||||
|
executed.stderr.toString() || executed.stdout.toString(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const errorMessage = executed.stderr.toString()
|
||||||
|
const message = executed.stdout.toString()
|
||||||
|
if (!!errorMessage) {
|
||||||
|
await effects.setHealth({
|
||||||
|
name: healthId,
|
||||||
|
status: "failure",
|
||||||
|
message: errorMessage,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await effects.setHealth({
|
||||||
|
name: healthId,
|
||||||
|
status: "passing",
|
||||||
|
message,
|
||||||
|
})
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
actionProcedure
|
actionProcedure
|
||||||
const moduleCode = await this.system.moduleCode
|
const moduleCode = await this.system.moduleCode
|
||||||
|
|||||||
Reference in New Issue
Block a user