Real-time terminal dashboard for monitoring the Axion scheduler service using the Rich library.
The Scheduler TUI provides a comprehensive, real-time view of the scheduler's operation including:
Current Status:
Lifetime Statistics:
Configuration:
Shows currently executing tasks:
Displays up to 10 most recent running tasks.
Shows tasks waiting for execution:
Displays up to 8 queued tasks.
Shows chronological event history:
Displays last 8 events.
# Start with TUI (default workers = CPU count)
python factory.core/ObjScheduler.py service --tui
# Or use short flag
python factory.core/ObjScheduler.py service -t
# Specify number of workers
python factory.core/ObjScheduler.py service --tui --workers 4
# Short flags
python factory.core/ObjScheduler.py service -t -w 4
# Run without TUI (logs to stdout)
python factory.core/ObjScheduler.py service
# With custom worker count
python factory.core/ObjScheduler.py service --workers 8
Press Ctrl+C to gracefully shutdown the scheduler and TUI.
ββββββββββββββββββββ
β Worker Process β
β β
β Task Execution β
ββββββββββ¬ββββββββββ
β
β Put event
βΌ
ββββββββββββββββ
β Event Queue β
ββββββββ¬ββββββββ
β
β Get event
βΌ
βββββββββββββββ
β Main Processβ
β β
β Process TUI β
β Events β
ββββββββ¬βββββββ
β
β record_event()
βΌ
βββββββββββ
β TUI β
βDashboardβ
βββββββββββ
Using multiprocessing.Manager():
running_tasks: Dict[GUID, TaskInfo] - Currently executing tasksqueued_tasks: Dict[GUID, QueueInfo] - Queued taskstask_queue: Queue - Tasks waiting for workersevent_queue: Queue - Events for TUI displayclass SchedulerTUI:
def __init__(
self,
running_tasks: Dict,
queued_tasks: Dict,
num_workers: int
):
"""Initialize scheduler TUI dashboard."""
def start(self) -> None:
"""Start the TUI in live mode."""
def stop(self) -> None:
"""Stop the TUI and cleanup."""
def log(self, message: str, level: str = "INFO") -> None:
"""
Add a log message.
Args:
message: Log message content
level: INFO, WARN, ERROR, SUCCESS
"""
def set_status(self, message: str) -> None:
"""Update status message in footer."""
def record_event(
self,
event_type: str,
guid: str,
message: str,
details: Optional[Dict] = None
) -> None:
"""
Record a task event.
Args:
event_type: START, COMPLETE, FAILED, RETRY
guid: Task GUID
message: Event message
details: Additional event information
"""
START: Task execution began
{
"type": "START",
"guid": "ABC123",
"message": "Task started",
"details": {"package": "homechoice"}
}
COMPLETE: Task finished successfully
{
"type": "COMPLETE",
"guid": "ABC123",
"message": "Task completed successfully",
"details": {"package": "homechoice"}
}
RETRY: Task failed, will retry
{
"type": "RETRY",
"guid": "ABC123",
"message": "Retry 2/3 after 4s",
"details": {
"retry_count": 2,
"backoff_seconds": 4,
"error": "Connection timeout"
}
}
FAILED: Task failed after max retries
{
"type": "FAILED",
"guid": "ABC123",
"message": "Failed after 3 retries",
"details": {"error": "Database connection failed"}
}
Error: TUI dependencies not available
Solution: Install Rich library
pip install rich
Problem: Garbled output or overlapping text
Solutions:
Problem: TUI updates slowly or freezes
Solutions:
Problem: Ctrl+C doesn't stop the service
Solution:
kill %1pkill -f ObjScheduler$ python factory.core/ObjScheduler.py service --tui --workers 4
βοΈ Axion Scheduler Dashboard | Workers: 4 | Uptime: 00:15:32
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Statistics ββ π Running Tasks (2) β
β ββββββββββββββ¬ββββββββββ¬βββββββ¬ββββββββββ
β π CURRENT STATUS ββGUID βPackage βStart βDuration β
β ββββββββββββββββββββββββββββββββββABC12345 βcore β14:20 β00:00:15 β
β π’ Running Tasks 2 ββDEF67890 βhomech.. β14:19 β00:01:23 β
β β³ Queued Tasks 3 βββββββββββββ΄ββββββββββ΄βββββββ΄ββββββββββ
β π· Active Workers 4 β
β βββββββββββββββββββββββββββββββββββββββββ
β π LIFETIME STATS ββ β³ Queued Tasks (3) β
β ββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ¬βββββββββ¬βββββββββ
β β
Completed 1,234ββGUID βRetriesβQueued βWait β
β β Failed 12ββGHI11111 β0/3 β14:21 β00:00:05β
β π Retries 45ββJKL22222 β1/3 β14:20 β00:00:42β
β π Success Rate 99.0%ββMNO33333 β0/3 β14:21 β00:00:03β
β βββββββββββββ΄ββββββββ΄βββββββββ΄βββββββββ
β βοΈ CONFIGURATION β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Max Retries 3 ββ π Recent Events β
β Backoff Base 2s ββββββββββ¬βββββββββ¬βββββββββββ¬ββββββββββ
β Poll Interval 10s ββTime βEvent βGUID βMessage β
ββββββββββββββββββββββββββββββββββββ14:21 ββ
DONE βABC12345 βCompletedβ
ββ14:20 βπ RETRYβJKL22222 βRetry 2/3β
ββ14:20 ββΆοΈ STARTβMNO33333 βStarted β
βββββββββ΄βββββββββ΄βββββββββββ΄ββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Status: Tick at 14:21:15 - Queued: 3, Running: 2
[14:21:10] [INFO] Task ABC12345 completed successfully
[14:21:12] [WARN] Task JKL22222 retry 2/3 after 4s
[14:21:15] [INFO] Scheduler tick
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ