Skip to content

Commit 6ba9158

Browse files
committed
fix: Quit registration if unable to connect
#15 Branch: Run-15 Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
1 parent 33ffe35 commit 6ba9158

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cforge/commands/server/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,18 @@ def run(
180180
# Wait for the server to come up
181181
server_url_base = f"http://{host}:{port}"
182182
start_time = time.time()
183+
ready = False
183184
while time.time() - start_time <= register_timeout:
184185
try:
185186
res = requests.get(f"{server_url_base}/healthz", timeout=0.1)
186187
if res.status_code == 200:
188+
ready = True
187189
break
188190
except requests.exceptions.ConnectionError:
189191
time.sleep(0.5)
192+
if not ready:
193+
console.print(f"[red]Failed to connect to server in {register_timeout}s[/red]")
194+
typer.exit(1)
190195

191196
# Build the server URL based on the protocol
192197
server_url = f"{server_url_base}{sse_path}" if is_sse else f"{server_url_base}/mcp"

0 commit comments

Comments
 (0)