feat: scaffold meshnet monorepo
This commit is contained in:
45
packages/gateway/meshnet_gateway/cli.py
Normal file
45
packages/gateway/meshnet_gateway/cli.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""meshnet-gateway CLI entry point."""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="meshnet-gateway",
|
||||
description="Distributed Inference Network HTTP gateway",
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
||||
start_cmd = subparsers.add_parser("start", help="Start the gateway server")
|
||||
start_cmd.add_argument("--tracker", default="http://localhost:8080", help="Tracker URL")
|
||||
start_cmd.add_argument(
|
||||
"--node-url",
|
||||
default="http://localhost:7000",
|
||||
help="Node URL to route to until tracker routing is implemented",
|
||||
)
|
||||
start_cmd.add_argument("--port", type=int, default=8080, help="Port to listen on")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == "start":
|
||||
from meshnet_gateway.server import GatewayServer
|
||||
|
||||
gateway = GatewayServer(node_url=args.node_url, port=args.port)
|
||||
port = gateway.start()
|
||||
print(f"meshnet-gateway listening on port {port}")
|
||||
print(f"Tracker URL: {args.tracker}")
|
||||
print(f"Routing to node URL: {args.node_url}")
|
||||
try:
|
||||
import time
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
gateway.stop()
|
||||
sys.exit(0)
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user