modified: app.py
This commit is contained in:
13
app.py
13
app.py
@@ -17,6 +17,16 @@ logging.basicConfig(level=logging.INFO)
|
|||||||
|
|
||||||
# Database configuration
|
# Database configuration
|
||||||
DATABASE_URL = os.getenv('DATABASE_URL')
|
DATABASE_URL = os.getenv('DATABASE_URL')
|
||||||
|
DB_HOST = os.getenv('DB_HOST')
|
||||||
|
DB_PORT = os.getenv('DB_PORT', '5432') # Default to PostgreSQL port
|
||||||
|
DB_NAME = os.getenv('DB_NAME')
|
||||||
|
DB_USER = os.getenv('DB_USER')
|
||||||
|
DB_PASSWORD = os.getenv('DB_PASSWORD')
|
||||||
|
|
||||||
|
# Build DATABASE_URL from individual components if not provided
|
||||||
|
if not DATABASE_URL and all([DB_HOST, DB_NAME, DB_USER, DB_PASSWORD]):
|
||||||
|
DATABASE_URL = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
||||||
|
print(f"📝 Built DATABASE_URL from individual environment variables")
|
||||||
|
|
||||||
# Global database connection pool
|
# Global database connection pool
|
||||||
db_pool = None
|
db_pool = None
|
||||||
@@ -546,7 +556,8 @@ async def main():
|
|||||||
|
|
||||||
if not DATABASE_URL:
|
if not DATABASE_URL:
|
||||||
print("❌ DATABASE_URL environment variable not found!")
|
print("❌ DATABASE_URL environment variable not found!")
|
||||||
print("Please set the DATABASE_URL variable in Coolify")
|
print("Please set either DATABASE_URL or individual DB variables (DB_HOST, DB_NAME, DB_USER, DB_PASSWORD) in Coolify")
|
||||||
|
print(f"Current values - HOST: {DB_HOST}, NAME: {DB_NAME}, USER: {DB_USER}, PASSWORD: {'***' if DB_PASSWORD else 'None'}")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user