Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit d7390e9

Browse files
authored
Merge pull request #4 from aarora79/dheeraj-work
uvicorn server websocket fix
2 parents a06b569 + 103a4d6 commit d7390e9

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ FROM python:3.12-slim
55
ENV PYTHONUNBUFFERED=1 \
66
DEBIAN_FRONTEND=noninteractive
77

8-
# Install system dependencies: nginx, curl (for health checks in registry), procps (for ps command used in stop script), openssl (for cert generation), git (needed by uv sometimes), build-essential (for potential C extensions)
8+
# Install system dependencies: nginx, curl (for health checks in registry), procps (for ps command used in stop script), openssl (for cert generation), git (needed by uv sometimes), build-essential (for potential C extensions), sudo (for sudo command)
99
RUN apt-get update && apt-get install -y --no-install-recommends \
1010
nginx \
1111
curl \
1212
procps \
1313
openssl \
1414
git \
1515
build-essential \
16+
sudo \
1617
&& apt-get clean \
1718
&& rm -rf /var/lib/apt/lists/*
1819

docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cd /app/registry
6262
# Use uv run to start uvicorn, ensuring it uses the correct environment
6363
# Run on 0.0.0.0 to be accessible within the container network
6464
# Use port 7860 as configured in nginx proxy_pass
65-
uv run uvicorn main:app --host 0.0.0.0 --port 7860 &
65+
sudo uv run uvicorn main:app --host 0.0.0.0 --port 7860 &
6666
echo "MCP Registry start command issued."
6767
# Give registry a moment to initialize and generate initial nginx config
6868
sleep 10

registry/main.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from fastapi.templating import Jinja2Templates
2626
from itsdangerous import URLSafeTimedSerializer, SignatureExpired, BadSignature
2727
from dotenv import load_dotenv
28+
import subprocess # Added for nginx reload
2829

2930
# --- MCP Client Imports --- START
3031
from mcp import ClientSession
@@ -180,7 +181,26 @@ def regenerate_nginx_config():
180181
with open(NGINX_CONFIG_PATH, 'w') as f_out:
181182
f_out.write(final_config)
182183
print("Nginx config regeneration successful.")
183-
return True
184+
185+
# --- Reload Nginx --- START
186+
try:
187+
print("Attempting to reload Nginx configuration...")
188+
# Ensure nginx command is available in PATH and process has permissions
189+
result = subprocess.run(['nginx', '-s', 'reload'], check=True, capture_output=True, text=True)
190+
print(f"Nginx reload successful. Output:\n{result.stdout}")
191+
# --- Reload Nginx --- END
192+
return True # Return True only if write AND reload succeed
193+
except FileNotFoundError:
194+
print("ERROR: 'nginx' command not found. Cannot reload configuration.")
195+
return False # Indicate failure if nginx command isn't found
196+
except subprocess.CalledProcessError as e:
197+
print(f"ERROR: Failed to reload Nginx configuration. Return code: {e.returncode}")
198+
print(f"Stderr: {e.stderr}")
199+
print(f"Stdout: {e.stdout}")
200+
return False # Indicate failure on reload error
201+
except Exception as e: # Catch other potential exceptions like permission errors
202+
print(f"ERROR: An unexpected error occurred during Nginx reload: {e}")
203+
return False # Indicate failure
184204

185205
except FileNotFoundError:
186206
print(f"ERROR: Nginx template file not found at {NGINX_TEMPLATE_PATH}")

0 commit comments

Comments
 (0)