55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
"""meshnet-node CLI entry point."""
|
|
|
|
import argparse
|
|
import sys
|
|
import time
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(
|
|
prog="meshnet-node",
|
|
description="Distributed Inference Network node client",
|
|
)
|
|
subparsers = parser.add_subparsers(dest="command")
|
|
|
|
start_cmd = subparsers.add_parser("start", help="Start the node server")
|
|
start_cmd.add_argument(
|
|
"--tracker", default="http://localhost:8080", help="Tracker URL"
|
|
)
|
|
start_cmd.add_argument("--port", type=int, default=7000, help="Port to listen on")
|
|
start_cmd.add_argument(
|
|
"--model", default="stub-model", help="Model preset to request from tracker"
|
|
)
|
|
start_cmd.add_argument(
|
|
"--host", default="0.0.0.0", help="Interface to bind to"
|
|
)
|
|
start_cmd.add_argument(
|
|
"--advertise-host",
|
|
help="Reachable host/IP to advertise to the tracker (defaults to FQDN when binding 0.0.0.0)",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.command == "start":
|
|
from meshnet_node.startup import run_startup
|
|
|
|
node = run_startup(
|
|
tracker_url=args.tracker,
|
|
port=args.port,
|
|
model=args.model,
|
|
host=args.host,
|
|
advertise_host=args.advertise_host,
|
|
)
|
|
try:
|
|
while True:
|
|
time.sleep(1)
|
|
except KeyboardInterrupt:
|
|
node.stop()
|
|
sys.exit(0)
|
|
else:
|
|
parser.print_help()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|