Небольшие доработки по трейсу

This commit is contained in:
2026-04-26 20:47:13 +03:00
parent 314e6f3c46
commit ed33f6e9cd
16 changed files with 725 additions and 27 deletions
+13 -7
View File
@@ -4,6 +4,7 @@ from time import monotonic, sleep
from app_runtime.config.providers import FileConfigProvider
from app_runtime.contracts.application import ApplicationModule
from app_runtime.control.base import ControlActionRequest
from app_runtime.control.service import ControlPlaneService
from app_runtime.core.configuration import ConfigurationManager
from app_runtime.core.registration import ModuleRegistry
@@ -87,7 +88,7 @@ class RuntimeManager:
async def health_status(self) -> HealthPayload:
return self.current_health()
async def start_runtime(self) -> dict[str, object] | str:
async def start_runtime(self, _request: ControlActionRequest) -> dict[str, object] | str:
self._refresh_state()
if self._started:
return "runtime already running"
@@ -100,24 +101,29 @@ class RuntimeManager:
return self._action_detail("runtime started", timed_out=False)
return self._action_detail("runtime start is still in progress", timed_out=True)
async def stop_runtime(self) -> dict[str, object] | str:
async def stop_runtime(self, request: ControlActionRequest) -> dict[str, object] | str:
self._refresh_state()
if not self._started:
if self._state == LifecycleState.STOPPING:
return self._action_detail("runtime stop is still in progress", timed_out=True)
return "runtime already stopped"
wait = True if request.wait is None else request.wait
timeout = self.ACTION_TIMEOUT_SECONDS if request.timeout is None else float(request.timeout)
force = False if request.force is None else request.force
self._state = LifecycleState.STOPPING
try:
self.workers.stop(timeout=self.ACTION_TIMEOUT_SECONDS, force=False)
self.workers.stop(timeout=timeout, force=force, wait=wait)
except TimeoutError:
return self._action_detail("runtime stop is still in progress", timed_out=True)
self._started = False
self._state = LifecycleState.STOPPED
return self._action_detail("runtime stopped", timed_out=False)
self._refresh_state()
if self._state == LifecycleState.STOPPED:
self._started = False
return self._action_detail("runtime stopped", timed_out=False)
return self._action_detail("runtime stop requested", timed_out=False)
async def runtime_status(self) -> str:
async def runtime_status(self, _request: ControlActionRequest) -> str:
self._refresh_state()
return self._state.value