-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgunicorn.conf.py
More file actions
44 lines (31 loc) · 1.18 KB
/
gunicorn.conf.py
File metadata and controls
44 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Gunicorn configuration and hooks for QuestByCycle."""
import os
from importlib import import_module
bind = os.getenv("GUNICORN_BIND", f"127.0.0.1:{os.getenv('PORT', '5000')}")
workers = int(os.getenv("WEB_CONCURRENCY", "2"))
threads = int(os.getenv("GUNICORN_THREADS", "4"))
timeout = int(os.getenv("GUNICORN_TIMEOUT", "120"))
accesslog = "-"
errorlog = "-"
wsgi_app = os.getenv("WSGI_APP", "wsgi:app")
_scheduler_app = None
def when_ready(server):
"""Start the APScheduler in the master process."""
if os.getenv("ENABLE_SCHEDULER", "1") != "1":
server.log.info("Scheduler disabled by env")
return
module_name, app_name = wsgi_app.split(":", 1)
module = import_module(module_name)
app = getattr(module, app_name)
from app.scheduler import create_scheduler
server.log.info("Launching scheduler")
create_scheduler(app)
global _scheduler_app
_scheduler_app = app
def on_exit(server):
"""Shutdown the scheduler on graceful exit."""
global _scheduler_app
if _scheduler_app:
from app.scheduler import shutdown_scheduler
server.log.info("Shutting down scheduler")
shutdown_scheduler(_scheduler_app, wait=False)