Миграция оркестратора на Debian 13: platform layer, preflight, status/diagnostics и structured logging

This commit is contained in:
2026-05-03 02:16:52 +05:00
parent 18ff86058a
commit 52f1e5d909
12 changed files with 304 additions and 13 deletions
+36 -2
View File
@@ -1,11 +1,45 @@
let operationId = "";
function nowIso(): string {
return new Date().toISOString();
}
function ensureOperationId(): string {
if (!operationId) {
operationId = `op-${Date.now().toString(36)}`;
}
return operationId;
}
export function setOperationContext(id: string): void {
operationId = id;
}
function emit(level: "STEP" | "INFO" | "ERROR", message: string, stepName?: string, status?: "start" | "ok" | "fail"): void {
const payload = {
ts: nowIso(),
op_id: ensureOperationId(),
level,
step: stepName ?? null,
status: status ?? null,
message
};
console.log(`[hy2xs] ${JSON.stringify(payload)}`);
}
export function step(name: string): void {
console.log(`\n[hy2xs] ==> ${name}`);
emit("STEP", `==> ${name}`, name, "start");
}
export function stepDone(name: string): void {
emit("STEP", `<== ${name}`, name, "ok");
}
export function info(message: string): void {
console.log(`[hy2xs] ${message}`);
emit("INFO", message);
}
export function fail(message: string): never {
emit("ERROR", message, undefined, "fail");
throw new Error(message);
}