fix(diagnostic): aria-restart ueber Docker-Socket-API statt CLI (Container hat kein docker installiert)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+32
-15
@@ -1360,24 +1360,41 @@ const server = http.createServer((req, res) => {
|
||||
return;
|
||||
} else if (req.url === "/api/aria-restart" && req.method === "POST") {
|
||||
// Harter Restart — fuer Faelle wo doctor --fix nicht reicht (alive aber
|
||||
// haengender Run). docker restart killt PID 1 vom Container, alle Locks
|
||||
// weg, neuer State. Dauert ~10-20s bis ARIA wieder antwortet.
|
||||
// haengender Run). Geht ueber Docker-API (Socket), kein CLI noetig.
|
||||
// POST /containers/aria-core/restart?t=10 → SIGTERM, dann nach 10s SIGKILL.
|
||||
log("warn", "server", "HTTP /api/aria-restart — harter Container-Restart");
|
||||
broadcast({ type: "watchdog", status: "fixing", message: "ARIA wird hart neu gestartet (~15s)" });
|
||||
const exec = require("child_process").exec;
|
||||
exec("docker restart aria-core", { timeout: 30000 }, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
log("error", "server", `aria-restart fehlgeschlagen: ${err.message}`);
|
||||
broadcast({ type: "watchdog", status: "error", message: `Restart fehlgeschlagen: ${err.message}` });
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: err.message }));
|
||||
return;
|
||||
}
|
||||
log("info", "server", `aria-restart OK: ${(stdout || "").trim()}`);
|
||||
broadcast({ type: "watchdog", status: "fixed", message: "ARIA wurde neu gestartet — sollte gleich antworten" });
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: true, output: stdout }));
|
||||
const restartReq = http.request({
|
||||
socketPath: "/var/run/docker.sock",
|
||||
path: "/containers/aria-core/restart?t=10",
|
||||
method: "POST",
|
||||
headers: { "Content-Length": 0 },
|
||||
timeout: 30000,
|
||||
}, (dRes) => {
|
||||
let body = "";
|
||||
dRes.on("data", (c) => body += c);
|
||||
dRes.on("end", () => {
|
||||
// Docker-API: 204 = OK, 404 = container nicht da, 500 = anderer Fehler
|
||||
if (dRes.statusCode === 204) {
|
||||
log("info", "server", "aria-restart OK (Docker-API)");
|
||||
broadcast({ type: "watchdog", status: "fixed", message: "ARIA wurde neu gestartet — sollte gleich antworten" });
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: true }));
|
||||
} else {
|
||||
log("error", "server", `aria-restart Docker-API ${dRes.statusCode}: ${body.slice(0, 200)}`);
|
||||
broadcast({ type: "watchdog", status: "error", message: `Restart fehlgeschlagen: HTTP ${dRes.statusCode}` });
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: `Docker-API ${dRes.statusCode}: ${body}` }));
|
||||
}
|
||||
});
|
||||
});
|
||||
restartReq.on("error", (err) => {
|
||||
log("error", "server", `aria-restart Socket-Fehler: ${err.message}`);
|
||||
broadcast({ type: "watchdog", status: "error", message: `Restart fehlgeschlagen: ${err.message}` });
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: err.message }));
|
||||
});
|
||||
restartReq.end();
|
||||
return;
|
||||
} else if (req.url.startsWith("/shared/")) {
|
||||
// Dateien aus Shared Volume ausliefern (Bilder, Uploads)
|
||||
|
||||
Reference in New Issue
Block a user