v0.1.26: версия в /health, admin health и UI; ldflags VERSION; Makefile build фикс
This commit is contained in:
@@ -727,6 +727,7 @@ func jsonErr(w http.ResponseWriter, code int, msg string) {
|
||||
// adminHealthDetail — ответ GET /admin/health
|
||||
type adminHealthDetail struct {
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
TenantCount int `json:"tenant_count"`
|
||||
QueueCount int `json:"queue_count"`
|
||||
MessageCount int `json:"message_count"`
|
||||
@@ -750,6 +751,7 @@ func (h *Handler) detailedHealth(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(adminHealthDetail{
|
||||
Status: "ok",
|
||||
Version: models.Version,
|
||||
TenantCount: 1,
|
||||
QueueCount: queueCount,
|
||||
MessageCount: msgCount,
|
||||
@@ -768,6 +770,7 @@ func (h *Handler) detailedHealth(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(adminHealthDetail{
|
||||
Status: "ok",
|
||||
Version: models.Version,
|
||||
TenantCount: len(tenants),
|
||||
QueueCount: queueCount,
|
||||
MessageCount: msgCount,
|
||||
|
||||
@@ -4,6 +4,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Version — версия сервиса. Переопределяется при сборке:
|
||||
// -ldflags "-X shared-sqs/app/models.Version=<версия>"
|
||||
var Version = "dev"
|
||||
|
||||
var BaseXmlns = "http://queue.amazonaws.com/doc/2012-11-05/"
|
||||
var BaseResponseMetadata = ResponseMetadata{RequestId: "00000000-0000-0000-0000-000000000000"}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
sqs "shared-sqs/app/gosqs"
|
||||
"shared-sqs/app/interfaces"
|
||||
"shared-sqs/app/metrics"
|
||||
"shared-sqs/app/models"
|
||||
"shared-sqs/app/tenant"
|
||||
"shared-sqs/app/ui"
|
||||
|
||||
@@ -125,8 +126,9 @@ var routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractR
|
||||
}
|
||||
|
||||
func health(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(200)
|
||||
fmt.Fprint(w, "OK")
|
||||
fmt.Fprintf(w, `{"status":"ok","version":%q}`, models.Version)
|
||||
}
|
||||
|
||||
func actionHandler(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
+14
-1
@@ -346,7 +346,8 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }
|
||||
<div>SQS API: <span style="font-family:monospace">POST /</span> (AWS Signature V4, регион <span style="font-family:monospace">us-east-1</span>)</div>
|
||||
<div>Admin API: <span style="font-family:monospace">POST /admin/tenants</span> (Bearer token)</div>
|
||||
<div>Realm: <span style="font-family:monospace">iot-naeel</span> · Persistence: Managed Redis</div>
|
||||
<div>Образ: <span style="font-family:monospace">naeel/shared-sqs:latest</span></div>
|
||||
<div>Версия: <span id="svc-version" style="font-family:monospace">—</span></div>
|
||||
<div>Образ: <span style="font-family:monospace">naeel/shared-sqs:v0.1.26</span></div>
|
||||
<div style="margin-top:8px;color:var(--warning)">Статус: тестирование</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -496,6 +497,14 @@ let sessionEmail = null; // Email из JWT для отображения в
|
||||
}
|
||||
} catch(e) { /* corrupted — show login */ }
|
||||
}
|
||||
// Версия сервиса — берём из публичного /health и показываем на странице входа
|
||||
fetch(BASE + '/health')
|
||||
.then(r => r.json())
|
||||
.then(h => {
|
||||
const el = document.getElementById('svc-version');
|
||||
if (el && h.version) el.textContent = h.version;
|
||||
})
|
||||
.catch(() => { /* health недоступен — оставляем '—' */ });
|
||||
showLogin();
|
||||
})();
|
||||
|
||||
@@ -619,6 +628,10 @@ function renderDashboard(health, tenants) {
|
||||
<div class="stat-value" style="color:var(--success)">●</div>
|
||||
<div class="stat-label">${health.status || 'ok'}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:18px">${health.version || 'dev'}</div>
|
||||
<div class="stat-label">Версия</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="toolbar">
|
||||
|
||||
Reference in New Issue
Block a user