feat: add one-click deploy script + project optimization
- 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
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Gunicorn configuration for Squid Manager.
|
||||
|
||||
Usage:
|
||||
gunicorn -c gunicorn_config.py wsgi:app
|
||||
|
||||
All values can be overridden via environment variables:
|
||||
SQUIDMGR_HOST bind address (default: 0.0.0.0)
|
||||
SQUIDMGR_PORT bind port (default: 5200)
|
||||
SQUIDMGR_WORKERS worker count (default: 2)
|
||||
SQUIDMGR_TIMEOUT worker timeout (default: 120)
|
||||
"""
|
||||
import multiprocessing
|
||||
import os
|
||||
|
||||
_host = os.environ.get("SQUIDMGR_HOST", "0.0.0.0")
|
||||
_port = os.environ.get("SQUIDMGR_PORT", "5200")
|
||||
_workers = int(os.environ.get("SQUIDMGR_WORKERS", 2))
|
||||
_timeout = int(os.environ.get("SQUIDMGR_TIMEOUT", 120))
|
||||
|
||||
bind = f"{_host}:{_port}"
|
||||
workers = _workers
|
||||
timeout = _timeout
|
||||
worker_class = "sync"
|
||||
|
||||
# Logging
|
||||
accesslog = "-" # stdout → journald
|
||||
errorlog = "-" # stderr → journald
|
||||
loglevel = "info"
|
||||
|
||||
# Preload app to share memory & fail fast on import errors
|
||||
preload_app = True
|
||||
|
||||
# PID file (for health-check scripts)
|
||||
pidfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "instance", "gunicorn.pid")
|
||||
Reference in New Issue
Block a user