-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
38 lines (34 loc) · 1021 Bytes
/
server.py
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
"""
OPSource Production Server
Uses Waitress WSGI server for production deployment
"""
import logging
from pathlib import Path
from waitress import serve
from main import app
from dev_config import DEV_CONFIG
# Configure logging
logging.basicConfig(
level=getattr(logging, DEV_CONFIG.logging.level),
format='%(asctime)s - %(levelname)s - %(message)s',
filename=str(Path(DEV_CONFIG.logging.dir) / 'server.log'),
filemode='a'
)
logger = logging.getLogger(__name__)
def start_server():
"""Start the production server using waitress"""
try:
host = DEV_CONFIG.api.host
port = DEV_CONFIG.api.port
logger.info(f"Starting server on http://{host}:{port}")
serve(
app,
host=host,
port=port,
threads=DEV_CONFIG.api.workers * 4 # Recommended threads per worker
)
except Exception as e:
logger.error(f"Failed to start server: {str(e)}")
raise
if __name__ == '__main__':
start_server()