Run alembic migration in gunicorn on_start hoook

This commit is contained in:
Josef Skladanka 2025-04-07 09:50:12 +02:00
commit c88d52da3d
3 changed files with 18 additions and 7 deletions

View file

@ -1,2 +1,2 @@
UPGRADE_PIP_TO_LATEST=1
APP_CONFIG=/opt/app-root/src/gunicorn.cfg
APP_CONFIG=/opt/app-root/src/gunicorn.cfg.py

View file

@ -1,6 +0,0 @@
import logging
import sys
gunicorn_logger = logging.getLogger('gunicorn.error')
gunicorn_logger.addHandler(logging.StreamHandler(sys.stdout))
bind = "0.0.0.0:8080"

17
gunicorn.cfg.py Normal file
View file

@ -0,0 +1,17 @@
import logging
import subprocess
import sys
import os
def on_starting(server):
"""Executes code before the master process is initialized"""
print("GUNICORN ON STARTING HOOOK")
os.system("python run_cli.py upgrade_db")
print("LOADING gunnicorn.cfg.py")
gunicorn_logger = logging.getLogger("gunicorn.error")
gunicorn_logger.addHandler(logging.StreamHandler(sys.stdout))
bind = "0.0.0.0:8080"