(args: list[str])
| 584 | |
| 585 | |
| 586 | def _cmd_serve(args: list[str]) -> None: |
| 587 | flags, _ = _parse_flags(args, { |
| 588 | "port": True, |
| 589 | "host": True, |
| 590 | "upstream": True, |
| 591 | "composition-config": True, |
| 592 | "daemon": False, |
| 593 | "background": False, |
| 594 | }) |
| 595 | |
| 596 | from uncommon_route.proxy import DEFAULT_PORT |
| 597 | |
| 598 | port = int(flags.get("port", DEFAULT_PORT)) |
| 599 | host = str(flags.get("host", "127.0.0.1")) |
| 600 | upstream = str(flags.get("upstream", "")).strip() or None |
| 601 | composition_config = str(flags.get("composition-config", "")).strip() |
| 602 | daemon = bool(flags.get("daemon") or flags.get("background")) |
| 603 | |
| 604 | if daemon: |
| 605 | started, message = _start_background_proxy( |
| 606 | port=port, |
| 607 | host=host, |
| 608 | upstream=upstream, |
| 609 | composition_config=composition_config, |
| 610 | ) |
| 611 | print(f" {message}") |
| 612 | if not started: |
| 613 | return |
| 614 | print(f" Logs: {_LOG_FILE}") |
| 615 | print(" Stop: uncommon-route stop") |
| 616 | return |
| 617 | |
| 618 | from uncommon_route.proxy import serve |
| 619 | if composition_config: |
| 620 | os.environ["UNCOMMON_ROUTE_COMPOSITION_CONFIG"] = composition_config |
| 621 | serve(port=port, host=host, upstream=upstream) |
| 622 | |
| 623 | |
| 624 | def _cmd_stop(args: list[str]) -> None: |
nothing calls this directly
no test coverage detected