feat: Add task launcher API with timestamp-based run directories
- Add POST /runtime/start, /stop, /restart APIs - Run directories use timestamp format: YYYYMMDD_HHMMSS - Add force stop support in TradingRuntimeManager - Frontend: use REST API to start runtime instead of WebSocket - Remove RuntimeView page from navigation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from datetime import datetime, UTC
|
||||
from pathlib import Path
|
||||
@@ -10,6 +11,7 @@ from .context import TradingRunContext
|
||||
from .registry import RuntimeRegistry
|
||||
|
||||
_global_runtime_manager: Optional["TradingRuntimeManager"] = None
|
||||
_shutdown_event: Optional[asyncio.Event] = None
|
||||
|
||||
|
||||
def set_global_runtime_manager(manager: "TradingRuntimeManager") -> None:
|
||||
@@ -26,6 +28,28 @@ def get_global_runtime_manager() -> Optional["TradingRuntimeManager"]:
|
||||
return _global_runtime_manager
|
||||
|
||||
|
||||
def set_shutdown_event(event: asyncio.Event) -> None:
|
||||
"""Set the global shutdown event for signaling runtime stop."""
|
||||
global _shutdown_event
|
||||
_shutdown_event = event
|
||||
|
||||
|
||||
def clear_shutdown_event() -> None:
|
||||
"""Clear the global shutdown event."""
|
||||
global _shutdown_event
|
||||
_shutdown_event = None
|
||||
|
||||
|
||||
def get_shutdown_event() -> Optional[asyncio.Event]:
|
||||
"""Get the global shutdown event if set."""
|
||||
return _shutdown_event
|
||||
|
||||
|
||||
def is_shutdown_requested() -> bool:
|
||||
"""Check if shutdown has been requested."""
|
||||
return _shutdown_event is not None and _shutdown_event.is_set()
|
||||
|
||||
|
||||
class TradingRuntimeManager:
|
||||
def __init__(self, config_name: str, run_dir: Path, bootstrap: Optional[Dict[str, Any]] = None) -> None:
|
||||
self.config_name = config_name
|
||||
|
||||
Reference in New Issue
Block a user