This commit is contained in:
Slipstream 2025-05-08 20:50:01 -06:00
parent b63fdf62cb
commit 8ec547f923
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 35 additions and 13 deletions

View File

@ -24,8 +24,22 @@ else:
if __name__ == "__main__":
print(f"Starting API server on {host}:{port}")
import multiprocessing
def run_uvicorn(bind_host):
print(f"Starting API server on {bind_host}:{port}")
uvicorn.run(
"discordbot.api_service.api_server:app",
host=bind_host,
port=port
)
print(f"Data directory: {data_dir}")
# Use the full module path to ensure correct package context
# Removed reload=True to potentially fix import issues with the reloader
uvicorn.run("discordbot.api_service.api_server:app", host=host, port=port)
# Start both IPv4 and IPv6 servers
processes = []
for bind_host in ["0.0.0.0", "::"]:
p = multiprocessing.Process(target=run_uvicorn, args=(bind_host,))
p.start()
processes.append(p)
for p in processes:
p.join()

View File

@ -24,20 +24,19 @@ ssl_cert = os.getenv("SSL_CERT_FILE", "/etc/letsencrypt/live/slipstreamm.dev/ful
ssl_key = os.getenv("SSL_KEY_FILE", "/etc/letsencrypt/live/slipstreamm.dev/privkey.pem")
def run_unified_api():
"""Run the unified API service"""
try:
print(f"Starting unified API service on {api_host}:{api_port}")
"""Run the unified API service (dual-stack IPv4+IPv6)"""
import multiprocessing
# Check if SSL certificates exist and are configured
def run_uvicorn(bind_host):
print(f"Starting unified API service on {bind_host}:{api_port}")
ssl_available = ssl_cert and ssl_key and os.path.exists(ssl_cert) and os.path.exists(ssl_key)
if ssl_available:
print(f"Using SSL with certificates at {ssl_cert} and {ssl_key}")
uvicorn.run(
"api_server:app",
host=api_host,
host=bind_host,
port=api_port,
log_level="debug", # Increase log level
log_level="debug",
ssl_certfile=ssl_cert,
ssl_keyfile=ssl_key
)
@ -45,10 +44,19 @@ def run_unified_api():
print("SSL certificates not found or not configured. Starting without SSL (development mode)")
uvicorn.run(
"api_server:app",
host=api_host,
host=bind_host,
port=api_port,
log_level="debug" # Increase log level
log_level="debug"
)
try:
processes = []
for bind_host in ["0.0.0.0", "::"]:
p = multiprocessing.Process(target=run_uvicorn, args=(bind_host,))
p.start()
processes.append(p)
for p in processes:
p.join()
except Exception as e:
print(f"Error starting unified API service: {e}")