feat: improve session limit handling and add k6 load testing

This commit is contained in:
2026-04-23 05:17:53 +00:00
parent 47f46d5c5b
commit 1438dee21a
6 changed files with 687 additions and 156 deletions
+14 -5
View File
@@ -59,22 +59,31 @@ cat > /opt/portal/index.html <<HTML
rfb.scaleViewport = true;
rfb.resizeSession = true;
const enableHeartbeat = "${ENABLE_HEARTBEAT}" === "1";
const SESSION_CLOSED_URL = '/?session_closed=idle';
const SESSION_CLOSED_URL_BASE = '/?session_closed=';
const CLOSE_PATH = '${TOUCH_PATH}'.replace(/\/touch$/, '/close');
function goSessionClosed() {
function goSessionClosed(reason = 'idle') {
const safeReason = reason === 'limit' ? 'limit' : 'idle';
const target = `${SESSION_CLOSED_URL_BASE}${safeReason}`;
try {
if (window.top && window.top !== window) {
window.top.location.href = SESSION_CLOSED_URL;
window.top.location.href = target;
return;
}
} catch (e) {}
window.location.href = SESSION_CLOSED_URL;
window.location.href = target;
}
async function touch() {
try {
const res = await fetch('${TOUCH_PATH}', {method:'POST', credentials:'include'});
if (!res.ok) {
goSessionClosed();
let reason = 'idle';
try {
const payload = await res.json();
if (payload && typeof payload.reason === 'string') {
reason = payload.reason;
}
} catch (e) {}
goSessionClosed(reason);
}
} catch(e) {}
}