Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive

# 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)
# 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)
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx \
curl \
procps \
openssl \
git \
build-essential \
sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cd /app/registry
# Use uv run to start uvicorn, ensuring it uses the correct environment
# Run on 0.0.0.0 to be accessible within the container network
# Use port 7860 as configured in nginx proxy_pass
uv run uvicorn main:app --host 0.0.0.0 --port 7860 &
sudo uv run uvicorn main:app --host 0.0.0.0 --port 7860 &
echo "MCP Registry start command issued."
# Give registry a moment to initialize and generate initial nginx config
sleep 10
Expand Down
22 changes: 21 additions & 1 deletion registry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from fastapi.templating import Jinja2Templates
from itsdangerous import URLSafeTimedSerializer, SignatureExpired, BadSignature
from dotenv import load_dotenv
import subprocess # Added for nginx reload

# --- MCP Client Imports --- START
from mcp import ClientSession
Expand Down Expand Up @@ -180,7 +181,26 @@ def regenerate_nginx_config():
with open(NGINX_CONFIG_PATH, 'w') as f_out:
f_out.write(final_config)
print("Nginx config regeneration successful.")
return True

# --- Reload Nginx --- START
try:
print("Attempting to reload Nginx configuration...")
# Ensure nginx command is available in PATH and process has permissions
result = subprocess.run(['nginx', '-s', 'reload'], check=True, capture_output=True, text=True)
print(f"Nginx reload successful. Output:\n{result.stdout}")
# --- Reload Nginx --- END
return True # Return True only if write AND reload succeed
except FileNotFoundError:
print("ERROR: 'nginx' command not found. Cannot reload configuration.")
return False # Indicate failure if nginx command isn't found
except subprocess.CalledProcessError as e:
print(f"ERROR: Failed to reload Nginx configuration. Return code: {e.returncode}")
print(f"Stderr: {e.stderr}")
print(f"Stdout: {e.stdout}")
return False # Indicate failure on reload error
except Exception as e: # Catch other potential exceptions like permission errors
print(f"ERROR: An unexpected error occurred during Nginx reload: {e}")
return False # Indicate failure

except FileNotFoundError:
print(f"ERROR: Nginx template file not found at {NGINX_TEMPLATE_PATH}")
Expand Down
Loading