-
Notifications
You must be signed in to change notification settings - Fork 1
/
gunicorn_config.py
36 lines (26 loc) · 1.13 KB
/
gunicorn_config.py
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
import os
import sys
import traceback
workers = 4
worker_class = "gevent"
worker_connections = 256
bind = "0.0.0.0:{}".format(os.getenv("PORT"))
accesslog = "-"
# See AWS doc
# > We also recommend that you configure the idle timeout of your application
# to be larger than the idle timeout configured for the load balancer.
# > By default, Elastic Load Balancing sets the idle timeout value for your load balancer to 60 seconds.
# https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
on_aws = os.environ.get("NOTIFY_ENVIRONMENT", "") in ["production", "staging", "scratch", "dev"]
if on_aws:
keepalive = 75
def on_starting(server):
server.log.info("Starting Document Download API")
def worker_abort(worker):
worker.log.info("worker received ABORT {}".format(worker.pid))
for threadId, stack in sys._current_frames().items():
worker.log.error("".join(traceback.format_stack(stack)))
def on_exit(server):
server.log.info("Stopping Document Download API")
def worker_int(worker):
worker.log.info("worker: received SIGINT {}".format(worker.pid))