chore: add docker infrastructure, gists feature, attachment system, and admin CLI tools
- Add .dockerignore, Dockerfile, and docker compose targets to Makefile for containerized deployment - Implement gists router with CRUD operations, database schema, and polymorphic comment/vote reuse - Create attachment upload system with thumbnail generation, MIME detection, and storage path management - Add attachments_prune CLI command to clean orphaned attachment records and files - Introduce rate limiting middleware with 60 requests per minute window - Add custom 404 and 500 error handlers with SEO-optimized template responses - Extend database initialization with gists and attachments indexes plus upload site settings defaults - Update load_comments to include attachment mapping for comment resources - Register gists and uploads routers in main application and update AGENTS.md documentation
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
class ServiceMonitor {
|
||||
constructor() {
|
||||
this.pollInterval = 5000;
|
||||
}
|
||||
|
||||
start() {
|
||||
this.pollServices();
|
||||
setInterval(() => this.pollServices(), this.pollInterval);
|
||||
}
|
||||
|
||||
formatDate(isoStr, includeTime) {
|
||||
if (!isoStr) return "-";
|
||||
try {
|
||||
const d = new Date(isoStr);
|
||||
if (isNaN(d.getTime())) return isoStr.slice(0, 19);
|
||||
const dd = String(d.getDate()).padStart(2, "0");
|
||||
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const yyyy = d.getFullYear();
|
||||
if (includeTime) {
|
||||
const hh = String(d.getHours()).padStart(2, "0");
|
||||
const mi = String(d.getMinutes()).padStart(2, "0");
|
||||
return `${dd}/${mm}/${yyyy} ${hh}:${mi}`;
|
||||
}
|
||||
return `${dd}/${mm}/${yyyy}`;
|
||||
} catch {
|
||||
return isoStr.slice(0, 19);
|
||||
}
|
||||
}
|
||||
|
||||
async pollServices() {
|
||||
try {
|
||||
const resp = await fetch("/admin/services/data");
|
||||
const data = await resp.json();
|
||||
const container = document.getElementById("services-list");
|
||||
if (!container) return;
|
||||
for (const svc of data.services) {
|
||||
const card = container.querySelector(`.service-card[data-service="${svc.name}"]`);
|
||||
if (!card) continue;
|
||||
const statusEl = card.querySelector(".service-status");
|
||||
if (statusEl) {
|
||||
statusEl.textContent = svc.status;
|
||||
statusEl.className = "service-status " + svc.status;
|
||||
}
|
||||
const metaItems = card.querySelectorAll(".meta-item");
|
||||
if (metaItems.length >= 3) {
|
||||
metaItems[0].textContent = "Uptime: " + (svc.uptime || "-");
|
||||
metaItems[1].textContent = "Last run: " + this.formatDate(svc.last_run, true);
|
||||
metaItems[2].textContent = "Next run: " + this.formatDate(svc.next_run, true);
|
||||
}
|
||||
const logPre = card.querySelector(".log-output");
|
||||
if (logPre) {
|
||||
logPre.textContent = (svc.log_buffer || []).map((l) => l + "\n").join("") || "No log entries yet.\n";
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// silently ignore poll errors
|
||||
}
|
||||
}
|
||||
}
|
||||
window.ServiceMonitor = ServiceMonitor;
|
||||
Reference in New Issue
Block a user