-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
49 lines (40 loc) · 1.6 KB
/
run.py
File metadata and controls
49 lines (40 loc) · 1.6 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
#!/usr/bin/env python3
"""
Simple launcher script for the API server.
This makes it easier to run the server with standard options.
"""
import uvicorn
import argparse
import logging
import os
def main():
parser = argparse.ArgumentParser(description="Run the Document Embedding API server")
parser.add_argument("--host", default="0.0.0.0", help="Host to bind the server to")
parser.add_argument("--port", type=int, default=8000, help="Port to bind the server to")
parser.add_argument("--reload", action="store_true", help="Enable auto-reload (for development)")
parser.add_argument("--log-level", default="info", choices=["debug", "info", "warning", "error", "critical"],
help="Logging level")
parser.add_argument("--workers", type=int, default=1, help="Number of worker processes")
args = parser.parse_args()
# Configure logging
log_level = getattr(logging, args.log_level.upper())
logging.basicConfig(
level=log_level,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger("document-embedding-api")
logger.info(f"Starting Document Embedding API on {args.host}:{args.port}")
logger.info(f"Log level set to: {args.log_level.upper()}")
if args.reload:
logger.info("Auto-reload enabled (development mode)")
# Run the API server
uvicorn.run(
"main:app",
host=args.host,
port=args.port,
reload=args.reload,
workers=args.workers,
log_level=args.log_level.lower()
)
if __name__ == "__main__":
main()