MCPcopy
hub / github.com/ray-project/ray / controller_health

Function controller_health

python/ray/serve/scripts.py:805–846  ·  view source on GitHub ↗
(address: str, output_json: bool)

Source from the content-addressed store, hash-verified

803 help="Output metrics as JSON instead of formatted YAML.",
804)
805def controller_health(address: str, output_json: bool):
806 if not ray.is_initialized():
807 # Connect to existing cluster only, don't start a new one
808 try:
809 ray.init(
810 address=address,
811 namespace=SERVE_NAMESPACE,
812 )
813 except ConnectionError:
814 cli_logger.error(
815 f"Could not connect to Ray cluster at address '{address}'. "
816 "Make sure a Ray cluster is running."
817 )
818 sys.exit(1)
819
820 try:
821 # Get the controller handle
822 controller = _get_global_client()._controller
823
824 # Fetch health metrics
825 metrics = ray.get(controller.get_health_metrics.remote())
826
827 if output_json:
828 print(json.dumps(metrics, indent=2))
829 else:
830 print(
831 yaml.dump(
832 metrics,
833 default_flow_style=False,
834 sort_keys=False,
835 ),
836 end="",
837 )
838 except RayServeException as e:
839 cli_logger.error(str(e))
840 sys.exit(1)
841 except Exception:
842 cli_logger.error(
843 "Failed to get controller health metrics, "
844 "see the controller logs for more details."
845 )
846 sys.exit(1)
847
848
849@cli.command(

Callers

nothing calls this directly

Calls 9

_get_global_clientFunction · 0.90
printFunction · 0.85
getMethod · 0.65
is_initializedMethod · 0.45
initMethod · 0.45
errorMethod · 0.45
exitMethod · 0.45
remoteMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…