-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
68 lines (56 loc) · 2.58 KB
/
run.py
File metadata and controls
68 lines (56 loc) · 2.58 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
#!/usr/bin/env python3
"""
arXiv Paper Crawler - Application Entry Point
Usage:
python run.py
Or with custom settings:
APP_HOST=127.0.0.1 APP_PORT=8080 python run.py
"""
import sys
from pathlib import Path
# Add project root to Python path
project_root = Path(__file__).resolve().parent
sys.path.insert(0, str(project_root))
import uvicorn
from config import settings
def main():
"""Run the application."""
print(f"""
╔═══════════════════════════════════════════════════════════╗
║ ║
║ 📚 arXiv Paper Crawler ║
║ ║
║ Starting server at http://{settings.app_host}:{settings.app_port} ║
║ ║
║ API Docs: http://{settings.app_host}:{settings.app_port}/docs ║
║ ReDoc: http://{settings.app_host}:{settings.app_port}/redoc ║
║ ║
╚═══════════════════════════════════════════════════════════╝
""")
# Check if we can use reload mode (requires sufficient inotify watches)
# If inotify limit is too low, disable reload to avoid crashes
use_reload = settings.debug
if use_reload:
try:
# Check current inotify limit on Linux
with open('/proc/sys/fs/inotify/max_user_watches', 'r') as f:
max_watches = int(f.read().strip())
# Need at least 16384 watches for comfortable development
if max_watches < 16384:
print(f"⚠️ Warning: inotify watch limit is {max_watches}, too low for hot-reload.")
print(" Disabling hot-reload. To enable it, run:")
print(" sudo sysctl fs.inotify.max_user_watches=524288")
print()
use_reload = False
except (FileNotFoundError, PermissionError):
# Not on Linux or can't read the file, try reload anyway
pass
uvicorn.run(
"app.main:app",
host=settings.app_host,
port=settings.app_port,
reload=use_reload,
log_level="info" if settings.debug else "warning"
)
if __name__ == "__main__":
main()