mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 04:16:24 -05:00
Controller logs when it takes actions.
This commit is contained in:
parent
ccc6cf78d3
commit
9b3a03012e
9 changed files with 140 additions and 13 deletions
|
|
@ -6,10 +6,13 @@ for O(1) response times on API endpoints.
|
|||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import multiprocessing
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from controller.lib.status import (
|
||||
get_cpu_status,
|
||||
get_disk_bandwidth_status,
|
||||
|
|
@ -109,7 +112,7 @@ async def status_worker_loop(app, base_sleep: float = 5.0):
|
|||
app: FastAPI application instance
|
||||
base_sleep: Base sleep interval in seconds (default 5s)
|
||||
"""
|
||||
print("Status worker started")
|
||||
logger.info("Status worker started")
|
||||
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -123,10 +126,10 @@ async def status_worker_loop(app, base_sleep: float = 5.0):
|
|||
sleep_time = get_adaptive_sleep(status.get("load_stats"), base_sleep)
|
||||
|
||||
except asyncio.CancelledError:
|
||||
print("Status worker cancelled")
|
||||
logger.info("Status worker cancelled")
|
||||
raise
|
||||
except Exception as e:
|
||||
print(f"Status worker error: {e}")
|
||||
logger.error("Status worker error: %s", e)
|
||||
sleep_time = base_sleep
|
||||
|
||||
await asyncio.sleep(sleep_time)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue