2025-11-05 16:48:41 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""
|
|
|
|
|
Quick start script for NoteDiscovery
|
|
|
|
|
Run this to start the application without Docker
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys
|
2025-11-25 15:41:08 +00:00
|
|
|
import os
|
2025-11-05 16:48:41 +00:00
|
|
|
import subprocess
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-01-02 15:57:15 +00:00
|
|
|
try:
|
|
|
|
|
import colorama
|
|
|
|
|
colorama.just_fix_windows_console()
|
|
|
|
|
except ImportError:
|
|
|
|
|
colorama = None
|
|
|
|
|
|
2026-01-16 11:12:51 +00:00
|
|
|
def get_port():
|
2026-06-30 15:07:51 +00:00
|
|
|
"""Get port from: 1) PORT env var, 2) config.yaml, 3) default 8000."""
|
2026-01-16 11:12:51 +00:00
|
|
|
if os.getenv("PORT"):
|
|
|
|
|
return os.getenv("PORT")
|
|
|
|
|
config_path = Path("config.yaml")
|
|
|
|
|
if config_path.exists():
|
|
|
|
|
try:
|
|
|
|
|
import yaml
|
|
|
|
|
with open(config_path, 'r', encoding='utf-8') as f:
|
2026-06-30 15:07:51 +00:00
|
|
|
cfg = yaml.safe_load(f) or {}
|
|
|
|
|
return str(cfg.get('server', {}).get('port', 8000))
|
2026-01-16 11:12:51 +00:00
|
|
|
except Exception:
|
2026-06-30 15:07:51 +00:00
|
|
|
pass
|
2026-01-16 11:12:51 +00:00
|
|
|
return "8000"
|
|
|
|
|
|
2026-06-30 15:07:51 +00:00
|
|
|
|
2025-11-05 16:48:41 +00:00
|
|
|
def main():
|
|
|
|
|
try:
|
2026-06-30 14:13:42 +00:00
|
|
|
import fastapi # noqa: F401
|
|
|
|
|
import uvicorn # noqa: F401
|
2025-11-05 16:48:41 +00:00
|
|
|
except ImportError:
|
2026-06-30 14:13:42 +00:00
|
|
|
print("Installing dependencies...")
|
2025-11-05 16:48:41 +00:00
|
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
|
2026-06-30 14:13:42 +00:00
|
|
|
|
2026-01-16 11:12:51 +00:00
|
|
|
port = get_port()
|
2026-06-30 15:07:51 +00:00
|
|
|
print(f"🚀 NoteDiscovery → http://localhost:{port} (Ctrl+C to stop)")
|
2026-06-30 14:13:42 +00:00
|
|
|
print()
|
|
|
|
|
|
2025-11-05 16:48:41 +00:00
|
|
|
subprocess.call([
|
|
|
|
|
sys.executable, "-m", "uvicorn",
|
|
|
|
|
"backend.main:app",
|
|
|
|
|
"--reload",
|
|
|
|
|
"--host", "0.0.0.0",
|
2026-01-18 15:00:01 +00:00
|
|
|
"--port", port,
|
|
|
|
|
"--timeout-graceful-shutdown", "2"
|
2025-11-05 16:48:41 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|
|
|
|
|
|