931a64dbc8
- deploy.sh: one-click deployment (squid + venv + pip + gunicorn + systemd) - gunicorn_config.py: unified gunicorn config with env var overrides - .env.example: env var template for SECRET_KEY, port, workers, security - wsgi.py: create all runtime dirs (uploads, ssl_certs); optional dotenv loading - requirements.txt: add python-dotenv + cryptography - .gitignore: cover runtime dirs, .env, pyc files
33 lines
915 B
Python
33 lines
915 B
Python
"""WSGI entry point for gunicorn.
|
|
|
|
Run with:
|
|
gunicorn --workers 2 --bind 0.0.0.0:5200 wsgi:app
|
|
|
|
Or via systemd unit.
|
|
"""
|
|
import os
|
|
|
|
# Ensure runtime dirs exist before app imports (it references SQLite path etc.)
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
for _d in ("instance", "backups", "uploads", "ssl_certs"):
|
|
os.makedirs(os.path.join(BASE_DIR, _d), exist_ok=True)
|
|
|
|
# Optional: load .env file if python-dotenv is available
|
|
try:
|
|
from dotenv import load_dotenv
|
|
_env_path = os.path.join(BASE_DIR, ".env")
|
|
if os.path.isfile(_env_path):
|
|
load_dotenv(_env_path)
|
|
except ImportError:
|
|
pass
|
|
|
|
from app import app, db, seed_admin
|
|
|
|
with app.app_context():
|
|
try:
|
|
db.create_all()
|
|
seed_admin()
|
|
except Exception as e:
|
|
# multi-worker race - the first worker wins; subsequent ones log
|
|
print(f"[wsgi] DB init: {e} (likely race with another worker)")
|