启动http服务
()
| 722 | |
| 723 | |
| 724 | def launch_api_server() -> None: |
| 725 | """ |
| 726 | 启动http服务 |
| 727 | """ |
| 728 | if not is_port_available(args.host, args.port): |
| 729 | raise Exception(f"The parameter `port`:{args.port} is already in use.") |
| 730 | |
| 731 | api_server_logger.info(f"launch Fastdeploy api server... port: {args.port}") |
| 732 | api_server_logger.info(f"args: {args.__dict__}") |
| 733 | # fd_start_span("FD_START") |
| 734 | |
| 735 | # Set control_socket_disable=True to prevent gunicorn.ctl file conflicts when multiple |
| 736 | # instances (e.g., Prefill and Decode services) run in the same directory (gunicorn 25.1.0+) |
| 737 | options = { |
| 738 | "bind": f"{args.host}:{args.port}", |
| 739 | "workers": args.workers, |
| 740 | "worker_class": "uvicorn.workers.UvicornWorker", |
| 741 | "loglevel": "info", |
| 742 | "graceful_timeout": args.timeout_graceful_shutdown, |
| 743 | "timeout": args.timeout, |
| 744 | "control_socket_disable": True, |
| 745 | } |
| 746 | |
| 747 | try: |
| 748 | StandaloneApplication(app, options).run() |
| 749 | except Exception as e: |
| 750 | api_server_logger.error(f"launch sync http server error, {e}, {str(traceback.format_exc())}") |
| 751 | |
| 752 | |
| 753 | metrics_app = FastAPI() |
no test coverage detected