-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
28 lines (25 loc) · 792 Bytes
/
run.py
File metadata and controls
28 lines (25 loc) · 792 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
import uvicorn
import socket
from app.core.config import settings
from app.core.logging import app_logger as logger
if __name__ == "__main__":
logger.info(f"Starting {settings.PROJECT_NAME} server...")
# Try to use port 8000, fallback to 8001 if in use
port = 8000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.bind(('', port))
sock.close()
except OSError:
port = 8001
logger.info(f"Port 8000 is in use, using port {port} instead")
# Uvicorn configuration
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=port,
reload=settings.ENVIRONMENT == "development",
log_config=None, # Use our custom logging
access_log=True,
use_colors=True
)