123456789101112131415161718192021222324252627282930 |
- import os
- import signal
- import sys
- import multiprocessing
- # 获取环境变量
- source_path = os.environ.get('SOURCE_PATH', '/usr/local/WTOAAM')
- # Gunicorn configuration settings
- bind = f"unix:{source_path}/djangoAPI.sock"
- workers = multiprocessing.cpu_count() * 2 + 1
- worker_class = "sync"
- timeout = 30
- loglevel = "info"
- def on_starting(server):
- print("Starting Gunicorn...")
- def when_ready(server):
- print("Gunicorn is ready")
- def on_exit(server):
- print("Stopping Gunicorn...")
- def pre_fork(server, worker):
- def handle_sigint(signal, frame):
- print("Received SIGINT, stopping Gunicorn...")
- server.stop()
- sys.exit(0)
- signal.signal(signal.SIGINT, handle_sigint)
|