-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api.py
More file actions
37 lines (30 loc) · 1009 Bytes
/
run_api.py
File metadata and controls
37 lines (30 loc) · 1009 Bytes
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
"""
Script to run the Vector Database API server.
This script starts the FastAPI application using uvicorn.
"""
import uvicorn
import logging
import os
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
if __name__ == "__main__":
# Get configuration from environment
host = os.getenv("API_HOST", "0.0.0.0")
port = int(os.getenv("API_PORT", "8000"))
reload = os.getenv("API_RELOAD", "false").lower() == "true"
workers = int(os.getenv("API_WORKERS", "1"))
logger.info(f"Starting Vector Database API on {host}:{port}")
logger.info(f"Workers: {workers}, Reload: {reload}")
logger.info("API Documentation available at /docs")
uvicorn.run(
"app.api.main:app",
host=host,
port=port,
reload=reload,
workers=workers if not reload else 1, # Reload doesn't work with multiple workers
log_level="info",
)