Files
photo-editor/public/js/health.js
Coder 401969cfdb
Some checks failed
test / test (push) Failing after 24s
v2: модульный монолит — очередь, персистентность, безопасность, SSE, тесты
Реализация целевого дизайна (docs/architecture/target-design.md):
- src/: модульная структура (config, logger, errors, http, core: auth/history/jobs/engines/comfy/codex/images)
- Очередь заданий: FIFO, кониурентность codex=1 / comfy-upscale=2, MAX_QUEUED_JOBS=5, JSONL-журнал и восстановление после рестарта (running → interrupted, upscale requeue)
- Персистентные сессии (sha256-хеши токенов), scrypt-хеш пароля, rate-limit входа, Origin-проверка, magic-byte валидация аплоадов
- Атомарная запись манифеста истории, каскадное удаление, URL с фактическим расширением + 302-алиас /image.jpg, миграция history/ → data/history
- Даунскейл sharp до 1024px перед Codex + масштабирование области референса
- SSE /api/events с фолбэком на polling, фронтенд переведён на ES-модули (public/js/)
- Тесты node:test + supertest (27), CI workflow test.yml, Docker/деплой: том kadr-data
- Документация: README, docs/architecture/
2026-08-27 12:52:27 +07:00

50 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* health.js — Проверка доступности сервера обработки ComfyUI
*/
export function setHealthState(state, message, title = "") {
const healthStatus = document.querySelector("#health-status");
const healthText = document.querySelector("#health-text");
if (!healthStatus || !healthText) return;
healthStatus.className = `health-status health-${state}`;
healthStatus.title = title || message;
healthText.textContent = message;
}
export async function checkHealth() {
try {
const response = await fetch("/api/health");
if (!response.ok) {
setHealthState("error", "Сервер обработки недоступен");
return;
}
const data = await response.json();
if (!data.comfyAvailable) {
setHealthState("error", data.message || "ComfyUI недоступен");
return;
}
const missing = data.missingNodes || [];
if (missing.length > 0) {
setHealthState(
"warn",
"Не хватает узлов ComfyUI",
`Отсутствуют узлы: ${missing.join(", ")}`
);
return;
}
setHealthState("ok", "Сервер обработки готов");
} catch {
setHealthState("error", "Не удалось проверить сервер обработки");
}
}
export function startHealthPolling(intervalMs = 30000) {
checkHealth();
return setInterval(checkHealth, intervalMs);
}