(address: str, output_json: bool)
| 803 | help="Output metrics as JSON instead of formatted YAML.", |
| 804 | ) |
| 805 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…