70 lines
2.7 KiB
PHP
70 lines
2.7 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$out = [];
|
|
|
|
chdir("/var/www/html");
|
|
$out["recent_commits"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='10 minutes ago' --oneline 2>&1 | head -10"))));
|
|
$out["current_tags"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -5"))));
|
|
|
|
// Check WEVIA Master registry state
|
|
$reg = @file_get_contents("/var/www/html/api/wevia-tool-registry.json");
|
|
$reg_data = @json_decode($reg, true);
|
|
$out["registry"] = [
|
|
"exists" => $reg !== false,
|
|
"size" => strlen($reg),
|
|
"tool_count" => is_array($reg_data) ? count($reg_data) : 0,
|
|
];
|
|
// Check if mermaid + pdf-premium already in registry
|
|
if (is_array($reg_data)) {
|
|
$has_mermaid = false; $has_pdf_prem = false;
|
|
foreach ($reg_data as $t) {
|
|
$id = $t["id"] ?? "";
|
|
if (stripos($id, "mermaid") !== false) $has_mermaid = true;
|
|
if (stripos($id, "pdf_premium") !== false || stripos($id, "pdf-premium") !== false) $has_pdf_prem = true;
|
|
}
|
|
$out["registry"]["has_mermaid_tool"] = $has_mermaid;
|
|
$out["registry"]["has_pdf_premium"] = $has_pdf_prem;
|
|
}
|
|
|
|
// Check Ethica infrastructure
|
|
$ethica = [];
|
|
foreach (["consent.wevup.app", "ethica-pipeline", "ecm.py"] as $name) {
|
|
$ethica[$name] = "check needed";
|
|
}
|
|
$ethica["consent_page"] = file_exists("/var/www/html/consent.html") || file_exists("/var/www/html/ethica.html");
|
|
$out["ethica"] = $ethica;
|
|
|
|
// Check SSE streaming files
|
|
$sse_files = [];
|
|
foreach (["ambre-claude-stream.php", "ambre-claude-pattern-sse.php", "wevia-sse-override.js"] as $f) {
|
|
$path = "/var/www/html/api/$f";
|
|
$path2 = "/var/www/html/js/$f";
|
|
if (file_exists($path)) $sse_files[$f] = filesize($path);
|
|
elseif (file_exists($path2)) $sse_files[$f] = filesize($path2);
|
|
}
|
|
$out["sse_files"] = $sse_files;
|
|
|
|
// Language detection currently
|
|
$w = @file_get_contents("/var/www/html/wevia.html");
|
|
$out["lang_detection"] = [
|
|
"detectLang_defined" => preg_match("/function detectLang/", $w),
|
|
"darija_check" => strpos($w, "darija") !== false,
|
|
"lang_var" => strpos($w, "var lang =") !== false,
|
|
];
|
|
|
|
// Purge cache helper existence
|
|
$out["cf_purge"] = file_exists("/var/www/html/api/ambre-cf-purge.php");
|
|
|
|
// Monitoring status
|
|
$monitoring = [];
|
|
foreach (["/opt/weval-ops/andon-monitor.sh", "/opt/weval-ops/phpfpm-watchdog.sh", "/opt/weval-ops/zombie-killer.sh"] as $s) {
|
|
$monitoring[basename($s)] = file_exists($s);
|
|
}
|
|
$out["monitoring_scripts"] = $monitoring;
|
|
|
|
// Current cascade load
|
|
$out["load"] = trim(@shell_exec("uptime"));
|
|
$out["cascade_health"] = @file_get_contents("http://127.0.0.1:4000/health", false, stream_context_create(["http"=>["timeout"=>3]])) ? "UP" : "DOWN";
|
|
|
|
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|