Fix Supervisor start error by adding proper uvicorn server configuration
This commit is contained in:
parent
3e265b4489
commit
6e056de87e
@ -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:
|
||||
|
15
main.py
15
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,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user