mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Add SIGTERM restart-warning broadcast and first-visit ToS modal
- Gateway: on SIGTERM, broadcast a "notice" event to every connected socket before shutting down, so an active call/stream doesn't just silently drop during a redeploy. - Web client: new "notice" event handling shows a non-dismissable restart-warning dialog; new ToS modal shown on first visit to the own-hosted instance (client.webspeak3.de only), versioned via localStorage, reopenable from the menu. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
741528220e
commit
73303e1229
3 files changed
+185
-3
No files matched your search
@@ -360,6 +360,23 @@ const heartbeatTimer = setInterval(() => {
|
||||
|
||||
wss.on("close", () => clearInterval(heartbeatTimer));
|
||||
|
||||
// Docker sends SIGTERM on `docker stop`/`docker compose up -d` (redeploy)
|
||||
// before the default ~10s grace period elapses. Warn every connected
|
||||
// browser tab so an active call/stream doesn't just silently drop, then
|
||||
// exit quickly rather than waiting out the grace period doing nothing.
|
||||
process.on("SIGTERM", () => {
|
||||
const payload = JSON.stringify({ type: "notice", messageKey: "restartNotice.body" });
|
||||
for (const socket of wss.clients) {
|
||||
try {
|
||||
socket.send(payload);
|
||||
} catch {
|
||||
/* socket already gone */
|
||||
}
|
||||
}
|
||||
console.log(`[gateway] SIGTERM received, notified ${wss.clients.size} client(s), shutting down`);
|
||||
setTimeout(() => process.exit(0), 500);
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
const scheme = tlsOptions ? "https" : "http";
|
||||
console.log(
|
||||
|
||||
Reference in new issue
Block a user