Fix env save-and-restart by deferring PM2 restart until after HTTP response.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-13 10:54:48 +08:00
parent c4753ffb89
commit 1bda78ceb2
5 changed files with 69 additions and 27 deletions
+5 -1
View File
@@ -335,7 +335,11 @@
}
async function restartInstance() {
await fetchJson("/api/admin/restart", { method: "POST" });
try {
await fetchJson("/api/admin/restart", { method: "POST" });
} catch (_) {
// 重启会中断当前 HTTP 连接;只要后续 health 恢复即视为成功.
}
const deadline = Date.now() + 90000;
while (Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 2000));