mirror of
https://github.com/trycua/computer.git
synced 2026-02-18 12:28:51 -06:00
Fixed watchdog test
This commit is contained in:
@@ -13,10 +13,16 @@ import argparse
|
||||
import sys
|
||||
|
||||
|
||||
async def test_connection(host="localhost", port=8000, keep_alive=False):
|
||||
async def test_connection(host="localhost", port=8000, keep_alive=False, container_name=None):
|
||||
"""Test connection to the Computer Server."""
|
||||
uri = f"ws://{host}:{port}/ws"
|
||||
print(f"Connecting to {uri}...")
|
||||
if container_name:
|
||||
# Container mode: use WSS with container domain and port 8443
|
||||
uri = f"wss://{container_name}.containers.cloud.trycua.com:8443/ws"
|
||||
print(f"Connecting to container {container_name} at {uri}...")
|
||||
else:
|
||||
# Local mode: use WS with specified host and port
|
||||
uri = f"ws://{host}:{port}/ws"
|
||||
print(f"Connecting to local server at {uri}...")
|
||||
|
||||
try:
|
||||
async with websockets.connect(uri) as websocket:
|
||||
@@ -54,13 +60,23 @@ def parse_args():
|
||||
parser = argparse.ArgumentParser(description="Test connection to Computer Server")
|
||||
parser.add_argument("--host", default="localhost", help="Host address (default: localhost)")
|
||||
parser.add_argument("--port", type=int, default=8000, help="Port number (default: 8000)")
|
||||
parser.add_argument("--container-name", help="Container name for cloud connection (uses WSS and port 8443)")
|
||||
parser.add_argument("--keep-alive", action="store_true", help="Keep connection alive")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
async def main():
|
||||
args = parse_args()
|
||||
success = await test_connection(args.host, args.port, args.keep_alive)
|
||||
|
||||
# Convert hyphenated argument to underscore for function parameter
|
||||
container_name = getattr(args, 'container_name', None)
|
||||
|
||||
success = await test_connection(
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
keep_alive=args.keep_alive,
|
||||
container_name=container_name
|
||||
)
|
||||
return 0 if success else 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user