Fix dashboard freeze: waitress, reduce frame refresh, atomic reads
- Switch Flask dev server -> waitress (8 threads, production WSGI) - Only refresh frame.jpg when frame_index changes, not every second - Safety try/except on send_file for edge-case file conflicts - Fix test_run.sh: export PYTHONPATH, use venv python - Update service file to use venv python
This commit is contained in:
1 parent
b9f4ba2ef8
commit
6cddf2c9d3
4 files changed
+16
-9
No files matched your search
@@ -121,11 +121,10 @@ function selectCam(id) {
|
||||
function poll() {
|
||||
if (!activeCam) return;
|
||||
var t = Date.now();
|
||||
var img = document.getElementById("frame-img");
|
||||
img.src = "/shm/" + activeCam + "/frame.jpg?t=" + t;
|
||||
fetch("/shm/" + activeCam + "/stats.json?t=" + t).then(r => r.ok ? r.json() : null).then(s => {
|
||||
if (!s) { setOffline(); return; }
|
||||
lastUpdate = Date.now();
|
||||
var oldFrame = lastFramePerCam[activeCam] || 0;
|
||||
lastFramePerCam[activeCam] = s.frame_index;
|
||||
perCam[activeCam] = { total: s.total_entered_count, inside: s.inside_box_count, frame: s.frame_index, tracks: s.track_count, speed: s.smoothed_speed };
|
||||
document.getElementById("s-total").textContent = s.total_entered_count;
|
||||
@@ -138,6 +137,10 @@ function poll() {
|
||||
tag.textContent = activeCam + " \u2022 " + status;
|
||||
tag.className = "tag " + (s.backward_active ? "off" : "live");
|
||||
document.getElementById("cam-count").textContent = s.total_entered_count;
|
||||
// only refresh frame when index changes (every 5 frames with interval_frames=5)
|
||||
if (s.frame_index != oldFrame) {
|
||||
document.getElementById("frame-img").src = "/shm/" + activeCam + "/frame.jpg?t=" + t;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user