Spaces:
Sleeping
Sleeping
Debug: Add health check endpoint and improved port handling
Browse files- Add / endpoint for health checks
- Prioritize PORT env var (HF Space standard)
- Add debug logging for port number
- Help diagnose routing issues
- .vscode/settings.json +5 -0
- vader_mcp/mcp_output/start_mcp.py +14 -3
.vscode/settings.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"python-envs.defaultEnvManager": "ms-python.python:conda",
|
| 3 |
+
"python-envs.defaultPackageManager": "ms-python.python:conda",
|
| 4 |
+
"python-envs.pythonProjects": []
|
| 5 |
+
}
|
vader_mcp/mcp_output/start_mcp.py
CHANGED
|
@@ -15,9 +15,20 @@ from mcp_service import create_app
|
|
| 15 |
def main():
|
| 16 |
"""Start FastMCP service"""
|
| 17 |
app = create_app()
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# Choose transport mode based on environment variable
|
| 22 |
transport = os.environ.get("MCP_TRANSPORT", "stdio")
|
| 23 |
if transport == "http":
|
|
|
|
| 15 |
def main():
|
| 16 |
"""Start FastMCP service"""
|
| 17 |
app = create_app()
|
| 18 |
+
|
| 19 |
+
# Add a health check endpoint at root
|
| 20 |
+
try:
|
| 21 |
+
@app.app.get("/")
|
| 22 |
+
async def health_check():
|
| 23 |
+
return {"status": "ok", "service": "vaderSentiment_service", "mcp_endpoint": "/mcp"}
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"Warning: Could not add health check endpoint: {e}")
|
| 26 |
+
|
| 27 |
+
# Use environment variable to configure port
|
| 28 |
+
# Check both PORT (HF standard) and MCP_PORT, default to 7860
|
| 29 |
+
port = int(os.environ.get("PORT", os.environ.get("MCP_PORT", "7860")))
|
| 30 |
+
print(f"Starting server on port {port}")
|
| 31 |
+
|
| 32 |
# Choose transport mode based on environment variable
|
| 33 |
transport = os.environ.get("MCP_TRANSPORT", "stdio")
|
| 34 |
if transport == "http":
|