fix(conversation-assistant): fix service registry discovery in install.sh
- Change from GET with query params to POST with JSON body - Fix response parsing: 'instances' → 'services' to match API - Prefer host (domain) over ipAddress for proper SSL/routing - Auto-detect https scheme for domain names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a44fce3a4d
commit
3616fd4a1d
1 changed files with 16 additions and 8 deletions
|
|
@ -158,22 +158,30 @@ discover_service_url() {
|
|||
# Try to discover conversation-assistant service from service-registry
|
||||
local registry_url="${SERVICE_REGISTRY_URL:-http://localhost:30000}"
|
||||
|
||||
# Try to discover the service
|
||||
# Try to discover the service (POST with JSON body)
|
||||
local discovery_response
|
||||
discovery_response=$(curl -s --connect-timeout 2 "$registry_url/registry/discover?serviceName=conversation-assistant&healthy=true" 2>/dev/null || echo "")
|
||||
discovery_response=$(curl -s --connect-timeout 2 \
|
||||
-X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"serviceName":"conversation-assistant","healthy":true}' \
|
||||
"$registry_url/registry/discover" 2>/dev/null || echo "")
|
||||
|
||||
if [[ -n "$discovery_response" && "$discovery_response" != *"error"* ]]; then
|
||||
# Parse the first instance's URL from JSON response
|
||||
# Parse the first service's URL from JSON response
|
||||
local service_url
|
||||
service_url=$(echo "$discovery_response" | python3 -c "
|
||||
import sys, json
|
||||
try:
|
||||
data = json.load(sys.stdin)
|
||||
if data.get('instances') and len(data['instances']) > 0:
|
||||
inst = data['instances'][0]
|
||||
ip = inst.get('ipAddress', 'localhost')
|
||||
port = inst.get('port', 3105)
|
||||
print(f'http://{ip}:{port}')
|
||||
services = data.get('services', [])
|
||||
if services and len(services) > 0:
|
||||
svc = services[0]
|
||||
# Prefer host (domain) over ipAddress for proper SSL/routing
|
||||
host = svc.get('host') or svc.get('ipAddress', 'localhost')
|
||||
port = svc.get('port', 3105)
|
||||
# Use https if host is a domain name
|
||||
scheme = 'https' if '.' in host and not host.replace('.','').isdigit() else 'http'
|
||||
print(f'{scheme}://{host}:{port}')
|
||||
except:
|
||||
pass
|
||||
" 2>/dev/null)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue