diff --git a/APP_PROFILER/routers/server.py b/APP_PROFILER/routers/server.py index 256daf8..7b2c45d 100644 --- a/APP_PROFILER/routers/server.py +++ b/APP_PROFILER/routers/server.py @@ -1,9 +1,13 @@ +import os +import logging from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session from database import get_db from utils.auth import verify_token from services import generator +logger = logging.getLogger(__name__) + router = APIRouter(dependencies=[Depends(verify_token)]) @router.post("/server/configure") diff --git a/APP_PROFILER/services/process.py b/APP_PROFILER/services/process.py index 327a05b..d2c28c7 100644 --- a/APP_PROFILER/services/process.py +++ b/APP_PROFILER/services/process.py @@ -200,6 +200,17 @@ def get_process_stats(): "uptime": None } +def get_os_type() -> str: + """ + Detects the host OS type to determine which service manager to use. + Currently supports: 'alpine', 'debian' (fallback for systemd systems). + """ + if os.path.exists("/etc/alpine-release"): + return "alpine" + + # Fallback to debian/ubuntu (systemd) + return "debian" + def format_seconds(seconds: float) -> str: seconds = int(seconds) days, seconds = divmod(seconds, 86400)