Start the web server with the given opencontext instance. Args: context_lab_instance: The opencontext instance to attach to the app host: Host address to bind to port: Port number to bind to workers: Number of worker processes config_path: Configuration f
(
context_lab_instance: OpenContext,
host: str,
port: int,
workers: int = 1,
config_path: str = None,
)
| 108 | |
| 109 | |
| 110 | def start_web_server( |
| 111 | context_lab_instance: OpenContext, |
| 112 | host: str, |
| 113 | port: int, |
| 114 | workers: int = 1, |
| 115 | config_path: str = None, |
| 116 | ) -> None: |
| 117 | """Start the web server with the given opencontext instance. |
| 118 | |
| 119 | Args: |
| 120 | context_lab_instance: The opencontext instance to attach to the app |
| 121 | host: Host address to bind to |
| 122 | port: Port number to bind to |
| 123 | workers: Number of worker processes |
| 124 | config_path: Configuration file path for multi-process mode |
| 125 | """ |
| 126 | global _config_path |
| 127 | _config_path = config_path |
| 128 | |
| 129 | if workers > 1: |
| 130 | logger.info(f"Starting with {workers} worker processes") |
| 131 | # For multi-process mode, use import string to avoid the warning |
| 132 | uvicorn.run("opencontext.cli:app", host=host, port=port, |
| 133 | log_level="info", workers=workers) |
| 134 | else: |
| 135 | # For single process mode, use the existing instance |
| 136 | app.state.context_lab_instance = context_lab_instance |
| 137 | uvicorn.run(app, host=host, port=port, log_level="info") |
| 138 | |
| 139 | |
| 140 | def parse_args() -> argparse.Namespace: |
no test coverage detected