diff --git a/app/db/session.py b/app/db/session.py index ab0f912..76d8a50 100644 --- a/app/db/session.py +++ b/app/db/session.py @@ -9,8 +9,19 @@ from sqlalchemy.orm import sessionmaker from app.core.config import settings, DB_DIR # Define database filepath - use DB_DIR from config -db_file = DB_DIR / "db.sqlite" -print(f"Database file path: {db_file}") +try: + db_file = DB_DIR / "db.sqlite" + print(f"Database file path: {db_file}") +except Exception as e: + # Fallback to a default path if there's an issue with DB_DIR + import os + from pathlib import Path + + fallback_dir = Path("/app/storage/db") + os.makedirs(fallback_dir, exist_ok=True) + db_file = fallback_dir / "db.sqlite" + print(f"Using fallback database path due to error: {e}") + print(f"Fallback database file path: {db_file}") # Ensure database directory exists with proper permissions try: diff --git a/main.py b/main.py index 3b0aed4..4895ec5 100644 --- a/main.py +++ b/main.py @@ -306,3 +306,18 @@ def test_db_connection(): "message": str(e), "traceback": traceback.format_exc(), } + + +if __name__ == "__main__": + import uvicorn + + # Configure uvicorn server with appropriate settings + uvicorn.run( + "main:app", + host="0.0.0.0", # Listen on all available network interfaces + port=8001, # Default port used by app-8001 + reload=False, # Disable auto-reload for production + workers=1, # Number of worker processes + log_level="info", + access_log=True, + )