Compare commits
5 Commits
fix/correc
...
v1.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0a3f73989 | ||
| 659f22f15b | |||
| 403bc91f33 | |||
| 0a73c5cb37 | |||
|
|
f07ca784b1 |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,3 +1,21 @@
|
|||||||
|
## [1.4.2](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.4.1...v1.4.2) (2026-03-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* systeme metrics chart ([403bc91](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/403bc91f33ca2253d698531e8c6bf0c28b40f5c8))
|
||||||
|
* t-001 a t-005 correctif ([bdb65a0](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/bdb65a09ff247f8fb3d22913a3426a89fad1d177))
|
||||||
|
* t-005 a t-0029 correctif ([c12387a](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/c12387ac947cde677e78fe77d914a904795d404c))
|
||||||
|
* use recette status log ([0a73c5c](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/0a73c5cb37c557568647684382440d95de7bf3ab))
|
||||||
|
|
||||||
|
## [1.4.1](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.4.0...v1.4.1) (2026-03-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* readme ([13457ce](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/13457ceb5a74686cd7a5e4180a87f130d1e2f73d))
|
||||||
|
* resolve production runtime issues ([8886e8b](https://gitea.malio.fr/MALIO-DEV/Supervisor/commit/8886e8b7dfe4fb6c9f90f3be7f2a64e23dd7cb3c))
|
||||||
|
|
||||||
# [1.4.0](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.3.1...v1.4.0) (2026-03-17)
|
# [1.4.0](https://gitea.malio.fr/MALIO-DEV/Supervisor/compare/v1.3.1...v1.4.0) (2026-03-17)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,12 @@ type ScriptResult = {
|
|||||||
downloadFolders: string[]
|
downloadFolders: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ApiErrorLike = {
|
||||||
|
data?: {
|
||||||
|
statusMessage?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
result: [payload: ScriptResult]
|
result: [payload: ScriptResult]
|
||||||
}>()
|
}>()
|
||||||
@@ -171,7 +177,15 @@ const runScript = async (key: string) => {
|
|||||||
downloadFolders: data.downloadFolders || []
|
downloadFolders: data.downloadFolders || []
|
||||||
})
|
})
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
message.value = (error as any)?.data?.statusMessage || "Erreur execution script"
|
const errorMessage =
|
||||||
|
typeof error === "object" &&
|
||||||
|
error !== null &&
|
||||||
|
"data" in error &&
|
||||||
|
typeof (error as ApiErrorLike).data?.statusMessage === "string"
|
||||||
|
? (error as ApiErrorLike).data?.statusMessage
|
||||||
|
: null
|
||||||
|
|
||||||
|
message.value = errorMessage || "Erreur execution script"
|
||||||
emit("result", {
|
emit("result", {
|
||||||
key,
|
key,
|
||||||
label: scripts.value.find((item) => item.key === key)?.label || key,
|
label: scripts.value.find((item) => item.key === key)?.label || key,
|
||||||
|
|||||||
@@ -24,17 +24,27 @@
|
|||||||
v-else
|
v-else
|
||||||
:key="`${row.label}-${row.url}`"
|
:key="`${row.label}-${row.url}`"
|
||||||
class="status-row"
|
class="status-row"
|
||||||
:class="row.status === 200 ? 'row-ok' : 'row-error'"
|
:class="row.ok ? 'row-ok' : 'row-error'"
|
||||||
>
|
>
|
||||||
<div class="flex items-center gap-3">
|
<div class="status-copy">
|
||||||
<span class="status-dot" :class="row.status === 200 ? 'dot-ok' : 'dot-error'" />
|
<div class="flex items-center gap-3">
|
||||||
<span class="font-display text-sm font-semibold text-m-text">
|
<span class="status-dot" :class="row.ok ? 'dot-ok' : 'dot-error'" />
|
||||||
{{ row.label }}
|
<span class="font-display text-sm font-semibold text-m-text">
|
||||||
|
{{ row.label }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="status-detail">
|
||||||
|
{{ row.detail }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="status-meta">
|
||||||
|
<span class="font-mono text-xs" :class="row.ok ? 'text-m-success' : 'text-m-error'">
|
||||||
|
{{ statusLabel(row) }}
|
||||||
|
</span>
|
||||||
|
<span class="status-time">
|
||||||
|
{{ formatCheckedAt(row.checkedAt) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="font-mono text-xs" :class="row.status === 200 ? 'text-m-success' : 'text-m-error'">
|
|
||||||
{{ statusLabel(row.status) }}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -51,6 +61,7 @@ interface StatusRow {
|
|||||||
ok: boolean
|
ok: boolean
|
||||||
status: number
|
status: number
|
||||||
checkedAt: string
|
checkedAt: string
|
||||||
|
detail: string
|
||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +85,24 @@ const loading = ref(true)
|
|||||||
const initialized = ref(false)
|
const initialized = ref(false)
|
||||||
let timer: ReturnType<typeof setInterval> | null = null
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
const statusLabel = (status: number) => {
|
const statusLabel = (row: StatusRow) => {
|
||||||
if (status === 200) return "HTTP 200"
|
if (row.ok) return "OK"
|
||||||
if (status === 0) return "Injoignable"
|
if (row.status === 0) return "DOWN"
|
||||||
return `KO (${status})`
|
return `KO (${row.status})`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatCheckedAt = (checkedAt: string) => {
|
||||||
|
const date = new Date(checkedAt)
|
||||||
|
|
||||||
|
if (Number.isNaN(date.getTime())) {
|
||||||
|
return checkedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
return date.toLocaleTimeString("fr-FR", {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit"
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkStatus = async () => {
|
const checkStatus = async () => {
|
||||||
@@ -95,6 +120,7 @@ const checkStatus = async () => {
|
|||||||
ok: false,
|
ok: false,
|
||||||
status: 0,
|
status: 0,
|
||||||
checkedAt: new Date().toISOString(),
|
checkedAt: new Date().toISOString(),
|
||||||
|
detail: "Lecture du statut impossible",
|
||||||
error: error instanceof Error ? error.message : String(error)
|
error: error instanceof Error ? error.message : String(error)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -149,6 +175,7 @@ onBeforeUnmount(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
min-height: 3.2rem;
|
min-height: 3.2rem;
|
||||||
padding: 0.85rem 1rem;
|
padding: 0.85rem 1rem;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
@@ -157,6 +184,30 @@ onBeforeUnmount(() => {
|
|||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-copy {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-detail {
|
||||||
|
margin: 0.35rem 0 0;
|
||||||
|
color: rgb(var(--m-muted));
|
||||||
|
font-size: 0.78rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 0.2rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-time {
|
||||||
|
font-size: 0.72rem;
|
||||||
|
color: rgb(var(--m-muted));
|
||||||
|
}
|
||||||
|
|
||||||
.row-ok {
|
.row-ok {
|
||||||
border-color: rgb(var(--m-success) / 0.08);
|
border-color: rgb(var(--m-success) / 0.08);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ const visibleHistory = computed(() => {
|
|||||||
return history.value.filter((point) => point.sampledAt >= minTimestamp)
|
return history.value.filter((point) => point.sampledAt >= minTimestamp)
|
||||||
})
|
})
|
||||||
|
|
||||||
const scaleMax = 100
|
const scaleMax = computed(() => 100)
|
||||||
|
|
||||||
const formatValue = (value: number) => `${Math.round(value)}%`
|
const formatValue = (value: number) => `${Math.round(value)}%`
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,160 @@
|
|||||||
import targets from "../config/version-status-targets.json"
|
import { readFile } from "node:fs/promises"
|
||||||
|
import { join } from "node:path"
|
||||||
|
|
||||||
const REQUEST_TIMEOUT_MS = 5000
|
type StatusEntry = {
|
||||||
|
checkedAt: string
|
||||||
|
status: "OK" | "DOWN"
|
||||||
|
host: string
|
||||||
|
detail: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusResult = {
|
||||||
|
label: string
|
||||||
|
url: string
|
||||||
|
ok: boolean
|
||||||
|
status: number
|
||||||
|
checkedAt: string
|
||||||
|
detail: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_RECETTE_SCRIPTS_DIR = "/home/malio/Malio-ops/RecetteScripts"
|
||||||
|
|
||||||
|
function parseEnvFile(content: string) {
|
||||||
|
const values: Record<string, string> = {}
|
||||||
|
|
||||||
|
for (const rawLine of content.split("\n")) {
|
||||||
|
const line = rawLine.trim()
|
||||||
|
|
||||||
|
if (!line || line.startsWith("#")) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const separatorIndex = line.indexOf("=")
|
||||||
|
if (separatorIndex === -1) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = line.slice(0, separatorIndex).trim()
|
||||||
|
const value = line.slice(separatorIndex + 1).trim()
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
values[key] = value.replace(/^['"]|['"]$/g, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
return values
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogFileName(date: Date) {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0")
|
||||||
|
const day = String(date.getDate()).padStart(2, "0")
|
||||||
|
|
||||||
|
return `app_health_${year}-${month}-${day}.log`
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStatusLine(line: string): StatusEntry | null {
|
||||||
|
const parts = line.split(" | ")
|
||||||
|
if (parts.length < 4) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const [checkedAt, status, host, ...detailParts] = parts
|
||||||
|
if ((status !== "OK" && status !== "DOWN") || !host) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
checkedAt,
|
||||||
|
status,
|
||||||
|
host,
|
||||||
|
detail: detailParts.join(" | ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildStatusResult(entry: StatusEntry): StatusResult {
|
||||||
|
return {
|
||||||
|
label: entry.host,
|
||||||
|
url: `http://${entry.host}/`,
|
||||||
|
ok: entry.status === "OK",
|
||||||
|
status: entry.status === "OK" ? 200 : 0,
|
||||||
|
checkedAt: entry.checkedAt,
|
||||||
|
detail: entry.detail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default defineEventHandler(async () => {
|
export default defineEventHandler(async () => {
|
||||||
const results = await Promise.all(
|
const recetteScriptsDir = process.env.RECETTE_SCRIPTS_DIR || DEFAULT_RECETTE_SCRIPTS_DIR
|
||||||
targets.map(async (target) => {
|
const envFilePath = join(recetteScriptsDir, ".env")
|
||||||
const controller = new AbortController()
|
|
||||||
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(target.url, {
|
const envFileContent = await readFile(envFilePath, "utf8")
|
||||||
method: "GET",
|
const envValues = parseEnvFile(envFileContent)
|
||||||
headers: { Accept: "application/json" },
|
const logDir = envValues.APP_LOG_DIR
|
||||||
signal: controller.signal
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
if (!logDir) {
|
||||||
label: target.label,
|
throw createError({
|
||||||
url: target.url,
|
statusCode: 500,
|
||||||
ok: response.status === 200,
|
statusMessage: "Variable APP_LOG_DIR manquante"
|
||||||
status: response.status,
|
})
|
||||||
checkedAt: new Date().toISOString()
|
}
|
||||||
}
|
|
||||||
} catch (error) {
|
const logFilePath = join(logDir, getLogFileName(new Date()))
|
||||||
return {
|
const logFileContent = await readFile(logFilePath, "utf8")
|
||||||
label: target.label,
|
const latestEntriesByHost = new Map<string, StatusEntry>()
|
||||||
url: target.url,
|
|
||||||
ok: false,
|
for (const line of logFileContent.split("\n")) {
|
||||||
status: 0,
|
const entry = parseStatusLine(line)
|
||||||
checkedAt: new Date().toISOString(),
|
if (!entry) {
|
||||||
error: error instanceof Error ? error.message : String(error)
|
continue
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
clearTimeout(timeoutId)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
return { results }
|
latestEntriesByHost.set(entry.host, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
const configuredHosts = (envValues.APP_URLS || "")
|
||||||
|
.split(/\s+/)
|
||||||
|
.map((host) => host.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
|
||||||
|
const orderedResults = configuredHosts
|
||||||
|
.map((host) => latestEntriesByHost.get(host))
|
||||||
|
.filter((entry): entry is StatusEntry => Boolean(entry))
|
||||||
|
.map(buildStatusResult)
|
||||||
|
|
||||||
|
const remainingResults = Array.from(latestEntriesByHost.entries())
|
||||||
|
.filter(([host]) => !configuredHosts.includes(host))
|
||||||
|
.map(([, entry]) => buildStatusResult(entry))
|
||||||
|
|
||||||
|
const results = [...orderedResults, ...remainingResults]
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 503,
|
||||||
|
statusMessage: "Aucun statut disponible"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
results
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erreur lecture status recette:", error)
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof error === "object" &&
|
||||||
|
error !== null &&
|
||||||
|
"statusCode" in error &&
|
||||||
|
"statusMessage" in error
|
||||||
|
) {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
|
||||||
|
throw createError({
|
||||||
|
statusCode: 500,
|
||||||
|
statusMessage: "Erreur lors de l'opération"
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
[
|
|
||||||
{ "label": "Ferme", "url": "http://ferme.malio-dev.fr/api/version" },
|
|
||||||
{ "label": "SIRH", "url": "http://sirh.malio-dev.fr/api/version" },
|
|
||||||
{ "label": "Inventory", "url": "http://inventory.malio-dev.fr/api/health" }
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user