Fix empty reply: remove gunicorn preload, isolate DB init from workers
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+18
-16
@@ -30,6 +30,7 @@ def create_app(setup_database=True):
|
||||
"postgresql://photohost:photohost_secret@localhost:5432/photohost",
|
||||
)
|
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {"pool_pre_ping": True}
|
||||
app.config["UPLOAD_FOLDER"] = os.getenv("UPLOAD_FOLDER", "uploads")
|
||||
app.config["MAX_CONTENT_LENGTH"] = int(os.getenv("MAX_UPLOAD_MB", "10")) * 1024 * 1024
|
||||
app.config["ALLOWED_EXTENSIONS"] = {"png", "jpg", "jpeg", "gif", "webp", "bmp"}
|
||||
@@ -68,25 +69,26 @@ def create_app(setup_database=True):
|
||||
except Exception:
|
||||
return {"site_banners": {}}
|
||||
|
||||
with app.app_context():
|
||||
from app.models import ( # noqa: F401
|
||||
AdBanner,
|
||||
Folder,
|
||||
FolderInvite,
|
||||
FolderMember,
|
||||
PasswordResetToken,
|
||||
Photo,
|
||||
SiteSettings,
|
||||
User,
|
||||
UserGroup,
|
||||
)
|
||||
if setup_database:
|
||||
with app.app_context():
|
||||
from app.models import ( # noqa: F401
|
||||
AdBanner,
|
||||
Folder,
|
||||
FolderInvite,
|
||||
FolderMember,
|
||||
PasswordResetToken,
|
||||
Photo,
|
||||
SiteSettings,
|
||||
User,
|
||||
UserGroup,
|
||||
)
|
||||
|
||||
db.create_all()
|
||||
db.create_all()
|
||||
|
||||
if setup_database and os.getenv("SKIP_DB_INIT") != "1":
|
||||
from app.bootstrap import run_database_setup
|
||||
if os.getenv("SKIP_DB_INIT") != "1":
|
||||
from app.bootstrap import run_database_setup
|
||||
|
||||
run_database_setup(app)
|
||||
run_database_setup(app)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user