fixed db problem

This commit is contained in:
2026-06-03 16:15:09 -04:00
parent 820ae5d50a
commit bc4f38726a
7 changed files with 49 additions and 2 deletions
+5
View File
@@ -7,10 +7,12 @@ services:
environment:
- HOST_BROWSE_ROOT=${HOST_BROWSE_ROOT}
- HOST_MOUNT_ROOT=/host
- DASHBOARD_DB_PATH=/app/data/dashboard.db
volumes:
- type: bind
source: ./server
target: /app
- db_data:/app/data
- type: bind
source: ${HOST_BROWSE_ROOT}
target: /host
@@ -37,3 +39,6 @@ services:
- frontend
restart: unless-stopped
volumes:
db_data:
+2
View File
@@ -147,6 +147,8 @@ def _create_default_user_if_missing(username, password, role):
def _ensure_default_users():
if count_users() > 0:
print("[server] Users already exist, skipping default account seeding.")
if count_users() == 0:
print("[server] No users found. Seeding default accounts...")
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12 -1
View File
@@ -6,9 +6,15 @@ import threading
from contextlib import contextmanager
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DB_PATH = os.path.join(BASE_DIR, "dashboard.db")
_DEFAULT_DB_PATH = os.path.join(BASE_DIR, "data", "dashboard.db")
if os.path.exists("/.dockerenv"):
_DEFAULT_DB_PATH = "/app/data/dashboard.db"
DB_PATH = os.getenv("DASHBOARD_DB_PATH", _DEFAULT_DB_PATH)
CONFIG_JSON = os.path.join(BASE_DIR, "config.json")
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
_conn = sqlite3.connect(DB_PATH, check_same_thread=False)
_conn.row_factory = sqlite3.Row
_lock = threading.RLock()
@@ -27,7 +33,12 @@ def _tx():
def _init_db():
with _tx():
try:
_conn.execute("PRAGMA journal_mode=WAL;")
except sqlite3.OperationalError as exc:
# Fallback for filesystems where WAL is unavailable.
print(f"[db] WAL unavailable ({exc}); falling back to DELETE journal mode")
_conn.execute("PRAGMA journal_mode=DELETE;")
_conn.executescript(
"""
CREATE TABLE IF NOT EXISTS config (
+29
View File
@@ -0,0 +1,29 @@
import os
import sys
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class TestResultsHandler(FileSystemEventHandler):
def __init__(self, callback):
super().__init__()
self.callback = callback
def on_created(self, event):
if event.is_directory:
print(f"[watcher] Detected new test result directory: {event.src_path}")
self.callback(event.src_path)
def start_watching_results_dir(results_dir, callback):
event_handler = TestResultsHandler(callback)
observer = Observer()
observer.schedule(event_handler, results_dir, recursive=False)
observer.start()
print(f"[watcher] Started watching for new test results in: {results_dir}")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()