hale-api / run.py
Raunak211006's picture
Deploy HALE API v3.1
0ca664b verified
Raw
History Blame Contribute Delete
856 Bytes
#!/usr/bin/env python
"""
run.py — Convenience script to start HALE in development mode.
Usage:
python run.py # dev server with hot reload
python run.py --prod # production mode (no reload)
python run.py --migrate # run alembic migrations then start
"""
import sys
import os
import subprocess
args = sys.argv[1:]
# Run Alembic migrations first if requested
if "--migrate" in args:
print("Running database migrations...")
result = subprocess.run(["alembic", "upgrade", "head"], check=True)
print("Migrations complete.")
args = [a for a in args if a != "--migrate"]
is_prod = "--prod" in args
import uvicorn
if __name__ == "__main__":
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=int(os.getenv("PORT", "8000")),
reload=not is_prod,
log_level="info",
)