-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_skyulf.py
More file actions
88 lines (74 loc) · 2.44 KB
/
run_skyulf.py
File metadata and controls
88 lines (74 loc) · 2.44 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
FastAPI Application Startup Script
© 2025 Murat Unsal — Skyulf Project
This script starts the FastAPI application with proper configuration.
It replaces the Flask run.py with modern async server capabilities.
"""
import logging
import sys
from backend.config import get_settings
from backend.utils.logging_utils import setup_universal_logging
from backend.main import app
def setup_logging():
"""Setup logging configuration."""
settings = get_settings()
# Use the unified logging setup which supports time-based rotation
setup_universal_logging(
log_file=settings.LOG_FILE,
log_level=settings.LOG_LEVEL,
rotation_type=settings.LOG_ROTATION_TYPE,
rotation_when=settings.LOG_ROTATION_WHEN,
rotation_interval=settings.LOG_ROTATION_INTERVAL,
max_bytes=settings.LOG_MAX_SIZE,
backup_count=settings.LOG_BACKUP_COUNT,
)
def main():
"""Main entry point for the FastAPI application."""
# Setup logging
setup_logging()
logger = logging.getLogger(__name__)
# Get settings
settings = get_settings()
# Log startup information
logger.info(f"[START] Starting {settings.APP_NAME}")
logger.info(
f"[ENV] Environment: {'Development' if settings.DEBUG else 'Production'}"
)
logger.info(f"[HOST] Host: {settings.HOST}:{settings.PORT}")
# Import uvicorn here to avoid import errors if not installed
try:
import uvicorn
except ImportError:
logger.error(
"[ERROR] uvicorn not installed. Please run: pip install uvicorn[standard]"
)
sys.exit(1)
# Development vs Production server configuration
if settings.DEBUG:
# Development server with auto-reload
logger.info("🔧 Running in development mode with auto-reload")
uvicorn.run(
"backend.main:app",
host=settings.HOST,
port=settings.PORT,
reload=True,
reload_dirs=["."],
log_level="info",
access_log=True,
use_colors=True,
)
else:
# Production server
logger.info("🏭 Running in production mode")
uvicorn.run(
app,
host=settings.HOST,
port=settings.PORT,
workers=settings.WORKERS,
log_level="warning",
access_log=False,
server_header=False,
date_header=False,
)
if __name__ == "__main__":
main()