65 lines
2.6 KiB
Python
Executable File
65 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Display the live Blender/WBV2 scheduler state.
|
|
|
|
The Node live-status command remains the source of truth for RUNNING, IDLE and
|
|
BLOCKED decisions.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from wbv2_runtime import CONTROL_ROOT, live_status, read_json
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--json", action="store_true", help="emit machine-readable status")
|
|
parser.add_argument("--watch", action="store_true")
|
|
parser.add_argument("--interval-ms", type=int, default=2000)
|
|
args = parser.parse_args()
|
|
result = live_status(json_only=True, watch=args.watch, interval_ms=args.interval_ms)
|
|
if result.returncode != 0:
|
|
if result.stderr:
|
|
print(result.stderr, end="")
|
|
return result.returncode
|
|
if args.watch:
|
|
# Preserve the Node tool's ANSI refresh and output contract for long
|
|
# running terminal sessions.
|
|
print(result.stdout, end="")
|
|
return 0
|
|
try:
|
|
status = json.loads(result.stdout)
|
|
except json.JSONDecodeError:
|
|
print(result.stdout, end="")
|
|
return 0
|
|
status["myTools"] = {
|
|
"watchdogStatus": read_json(CONTROL_ROOT / "my-tools-watchdog.json"),
|
|
"schedulerWrapperStatus": read_json(CONTROL_ROOT / "my-tools-scheduler.json"),
|
|
}
|
|
if args.json:
|
|
print(json.dumps(status, ensure_ascii=False, separators=(",", ":")))
|
|
return 0
|
|
print("Blender Web/WBV2 scheduler")
|
|
print(f" state: {status.get('state', 'UNKNOWN')}")
|
|
print(f" phase: {status.get('phase', 'unknown')}")
|
|
queue = status.get("queue", {})
|
|
print(f" current task: {queue.get('task') or 'none'}")
|
|
print(f" parent manifest: {queue.get('parentManifest') or 'none'}")
|
|
scheduler = status.get("scheduler", {})
|
|
print(f" scheduler: pid={scheduler.get('pid') or 'none'} alive={scheduler.get('alive', False)} state={scheduler.get('state') or 'unknown'}")
|
|
guardian = status.get("guardian", {})
|
|
supervisor = status.get("supervisor", {})
|
|
print(f" guardian: pid={guardian.get('pid') or 'none'} alive={guardian.get('alive', False)} state={guardian.get('state') or 'unknown'}")
|
|
print(f" supervisor: pid={supervisor.get('pid') or 'none'} alive={supervisor.get('alive', False)} state={supervisor.get('state') or 'unknown'}")
|
|
print(f" latest handoff: {status.get('latestHandoff') or 'none'}")
|
|
print(f" local HEAD: {status.get('localHead') or 'unknown'}")
|
|
print(f" message: {status.get('message', '')}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|