-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrailway_start.py
More file actions
59 lines (47 loc) Β· 1.7 KB
/
railway_start.py
File metadata and controls
59 lines (47 loc) Β· 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Railway startup script for AGS SPARQL Agent MCP Server
This ensures proper environment variable handling for Railway deployment
"""
import os
import sys
import subprocess
def main():
print("π Railway Startup Script")
print("=" * 50)
# Get Railway environment variables
host = os.getenv('HOST', '0.0.0.0')
port = os.getenv('PORT', '8000')
print(f"π Configuration:")
print(f" HOST: {host}")
print(f" PORT: {port}")
print(f" Python: {sys.version}")
print(f" Working Directory: {os.getcwd()}")
# Check required environment variables
required_vars = ['ANZO_SERVER', 'ANZO_USERNAME', 'ANZO_PASSWORD']
missing = [var for var in required_vars if not os.getenv(var)]
if missing:
print(f"β οΈ Warning: Missing environment variables: {missing}")
else:
print("β
All required environment variables found")
# Ensure HOST and PORT are set (Railway provides them)
os.environ['HOST'] = host
os.environ['PORT'] = str(port)
print(f"\nπ Starting Streamable HTTP server...")
print(f"π MCP endpoint: http://{host}:{port}/mcp")
print("=" * 50)
print()
# Start the server directly
try:
# Run the Python script directly in the same process
sys.path.insert(0, os.path.join(os.getcwd(), 'src'))
# Import and run the main function
from ags_sparql_agent_server import main as server_main
server_main()
except Exception as e:
print(f"β Failed to start server: {e}", file=sys.stderr)
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
main()