feat: Update application events and system state for improved dataset management and logging
This commit is contained in:
parent
71746fa326
commit
550fc78085
|
@ -1,97 +1,5 @@
|
|||
{
|
||||
"events": [
|
||||
{
|
||||
"timestamp": "2025-08-29T20:54:08.599367",
|
||||
"level": "info",
|
||||
"event_type": "performance_report",
|
||||
"message": "Performance report: 20 points saved, 0 lost, 0.2% CPU",
|
||||
"details": {
|
||||
"duration": 10.026997804641724,
|
||||
"points_saved": 20,
|
||||
"points_rate": 1.994614977450334,
|
||||
"variables_saved": 1,
|
||||
"udp_points_sent": 0,
|
||||
"points_lost": 0,
|
||||
"cpu_average": 0.2,
|
||||
"cpu_max": 0.2,
|
||||
"delay_average": 0.0,
|
||||
"delay_max": 0.0,
|
||||
"read_errors": 0,
|
||||
"csv_errors": 0,
|
||||
"udp_errors": 0,
|
||||
"read_time_avg": 0.08263550996780396,
|
||||
"csv_write_time_avg": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-29T20:54:18.626378",
|
||||
"level": "info",
|
||||
"event_type": "performance_report",
|
||||
"message": "Performance report: 20 points saved, 0 lost, 0.2% CPU",
|
||||
"details": {
|
||||
"duration": 10.027010917663574,
|
||||
"points_saved": 20,
|
||||
"points_rate": 1.994612368953146,
|
||||
"variables_saved": 1,
|
||||
"udp_points_sent": 0,
|
||||
"points_lost": 0,
|
||||
"cpu_average": 0.2,
|
||||
"cpu_max": 0.2,
|
||||
"delay_average": 0.0,
|
||||
"delay_max": 0.0,
|
||||
"read_errors": 0,
|
||||
"csv_errors": 0,
|
||||
"udp_errors": 0,
|
||||
"read_time_avg": 0.08589242696762085,
|
||||
"csv_write_time_avg": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-29T20:54:28.651774",
|
||||
"level": "info",
|
||||
"event_type": "performance_report",
|
||||
"message": "Performance report: 20 points saved, 0 lost, 0.6% CPU",
|
||||
"details": {
|
||||
"duration": 10.025396585464478,
|
||||
"points_saved": 20,
|
||||
"points_rate": 1.994933549960248,
|
||||
"variables_saved": 1,
|
||||
"udp_points_sent": 0,
|
||||
"points_lost": 0,
|
||||
"cpu_average": 0.6,
|
||||
"cpu_max": 0.6,
|
||||
"delay_average": 0.0,
|
||||
"delay_max": 0.0,
|
||||
"read_errors": 0,
|
||||
"csv_errors": 0,
|
||||
"udp_errors": 0,
|
||||
"read_time_avg": 0.08233990669250488,
|
||||
"csv_write_time_avg": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-29T20:54:38.676704",
|
||||
"level": "info",
|
||||
"event_type": "performance_report",
|
||||
"message": "Performance report: 20 points saved, 0 lost, 0.8% CPU",
|
||||
"details": {
|
||||
"duration": 10.024930238723755,
|
||||
"points_saved": 20,
|
||||
"points_rate": 1.9950263516792455,
|
||||
"variables_saved": 1,
|
||||
"udp_points_sent": 0,
|
||||
"points_lost": 0,
|
||||
"cpu_average": 0.8,
|
||||
"cpu_max": 0.8,
|
||||
"delay_average": 0.0,
|
||||
"delay_max": 0.0,
|
||||
"read_errors": 0,
|
||||
"csv_errors": 0,
|
||||
"udp_errors": 0,
|
||||
"read_time_avg": 0.08768099546432495,
|
||||
"csv_write_time_avg": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-29T20:54:48.701479",
|
||||
"level": "info",
|
||||
|
@ -22615,8 +22523,54 @@
|
|||
"read_time_avg": 0.11266074180603028,
|
||||
"csv_write_time_avg": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-30T23:19:06.425859",
|
||||
"level": "info",
|
||||
"event_type": "application_started",
|
||||
"message": "Application initialization completed successfully",
|
||||
"details": {}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-30T23:19:06.556130",
|
||||
"level": "info",
|
||||
"event_type": "dataset_activated",
|
||||
"message": "Dataset activated: DAR",
|
||||
"details": {
|
||||
"dataset_id": "DAR",
|
||||
"variables_count": 7,
|
||||
"streaming_count": 5,
|
||||
"prefix": "dar"
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-30T23:19:06.591481",
|
||||
"level": "info",
|
||||
"event_type": "dataset_activated",
|
||||
"message": "Dataset activated: Test",
|
||||
"details": {
|
||||
"dataset_id": "Test",
|
||||
"variables_count": 1,
|
||||
"streaming_count": 0,
|
||||
"prefix": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2025-08-30T23:19:06.626557",
|
||||
"level": "info",
|
||||
"event_type": "csv_recording_started",
|
||||
"message": "🔥 CRITICAL PRIORITY: CSV recording started with MAXIMUM PRIORITY, async buffering, and performance monitoring: 2 datasets activated",
|
||||
"details": {
|
||||
"activated_datasets": 2,
|
||||
"total_datasets": 2,
|
||||
"priority": "CRITICAL",
|
||||
"recording_protection": true,
|
||||
"performance_monitoring": true,
|
||||
"async_csv_buffering": true,
|
||||
"csv_flush_interval": 5.0
|
||||
}
|
||||
}
|
||||
],
|
||||
"last_updated": "2025-08-30T22:58:59.728072",
|
||||
"last_updated": "2025-08-30T23:19:06.626557",
|
||||
"total_entries": 1000
|
||||
}
|
46
main.py
46
main.py
|
@ -14,6 +14,7 @@ import requests # For HTTP health checks
|
|||
from datetime import datetime, timedelta, timezone
|
||||
import os
|
||||
import logging
|
||||
import pkgutil
|
||||
|
||||
# 📝 ROTATING LOGGER SYSTEM
|
||||
from core.rotating_logger import setup_backend_logging
|
||||
|
@ -252,10 +253,49 @@ def serve_public_record_png():
|
|||
@app.route("/SIDEL.png")
|
||||
def serve_public_sidel_png():
|
||||
"""Serve /SIDEL.png from the React public folder."""
|
||||
# Candidate locations to check (dev, build, executable-side)
|
||||
candidates = []
|
||||
|
||||
# frontend public (development)
|
||||
public_dir = resource_path(os.path.join("frontend", "public"))
|
||||
sidel_file = os.path.join(public_dir, "SIDEL.png")
|
||||
if os.path.exists(sidel_file):
|
||||
return send_from_directory(public_dir, "SIDEL.png")
|
||||
candidates.append((public_dir, "SIDEL.png"))
|
||||
|
||||
# frontend dist (production build)
|
||||
dist_dir = resource_path(os.path.join("frontend", "dist"))
|
||||
candidates.append((dist_dir, "SIDEL.png"))
|
||||
|
||||
# Also check next to the executable (PyInstaller -- onefile may extract or expect assets nearby)
|
||||
exec_dist = external_path(os.path.join("frontend", "dist", "SIDEL.png"))
|
||||
exec_dist_dir = os.path.dirname(exec_dist)
|
||||
candidates.append((exec_dist_dir, "SIDEL.png"))
|
||||
|
||||
# Also check for SIDEL.png sitting next to the executable
|
||||
exec_side = external_path("SIDEL.png")
|
||||
candidates.append((os.path.dirname(exec_side), os.path.basename(exec_side)))
|
||||
|
||||
# Try each candidate using send_from_directory when file exists
|
||||
for dir_path, filename in candidates:
|
||||
try:
|
||||
file_path = os.path.join(dir_path, filename)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if os.path.exists(file_path):
|
||||
# send_from_directory requires a real file on disk which should be true
|
||||
try:
|
||||
return send_from_directory(dir_path, filename)
|
||||
except Exception:
|
||||
# If send_from_directory fails for some reason, fall through to try reading bytes
|
||||
pass
|
||||
|
||||
# As a last resort, try to load the resource bytes (useful if bundled differently)
|
||||
try:
|
||||
data = pkgutil.get_data(__name__, os.path.join("frontend", "dist", "SIDEL.png"))
|
||||
if data:
|
||||
return Response(data, status=200, mimetype="image/png")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return Response("SIDEL.png not found", status=404, mimetype="text/plain")
|
||||
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
"should_connect": true,
|
||||
"should_stream": false,
|
||||
"active_datasets": [
|
||||
"DAR",
|
||||
"Test"
|
||||
"Test",
|
||||
"DAR"
|
||||
]
|
||||
},
|
||||
"auto_recovery_enabled": true,
|
||||
"last_update": "2025-08-30T22:54:50.154570"
|
||||
"last_update": "2025-08-30T23:19:06.662993"
|
||||
}
|
Loading…
Reference in New Issue