2018-02-06 15:12:12 +00:00
|
|
|
import os
|
2017-09-22 15:34:43 +01:00
|
|
|
import sys
|
|
|
|
|
import traceback
|
2019-10-23 12:40:19 +01:00
|
|
|
import gunicorn
|
2017-09-22 15:34:43 +01:00
|
|
|
|
2020-04-20 15:59:47 +01:00
|
|
|
from gds_metrics.gunicorn import child_exit # noqa
|
|
|
|
|
|
2018-03-29 14:57:19 +01:00
|
|
|
workers = 4
|
2018-02-06 15:12:12 +00:00
|
|
|
worker_class = "eventlet"
|
|
|
|
|
worker_connections = 256
|
|
|
|
|
errorlog = "/home/vcap/logs/gunicorn_error.log"
|
|
|
|
|
bind = "0.0.0.0:{}".format(os.getenv("PORT"))
|
2019-06-07 15:33:26 +01:00
|
|
|
statsd_host = "{}:8125".format(os.getenv("STATSD_HOST"))
|
2019-10-23 12:40:19 +01:00
|
|
|
gunicorn.SERVER_SOFTWARE = 'None'
|
2018-02-06 15:12:12 +00:00
|
|
|
|
2017-09-22 15:34:43 +01:00
|
|
|
|
2017-10-12 11:38:01 +01:00
|
|
|
def on_starting(server):
|
|
|
|
|
server.log.info("Starting Notifications API")
|
|
|
|
|
|
|
|
|
|
|
2017-09-22 15:03:45 +01:00
|
|
|
def worker_abort(worker):
|
2017-10-12 11:38:01 +01:00
|
|
|
worker.log.info("worker received ABORT {}".format(worker.pid))
|
2017-09-22 15:03:45 +01:00
|
|
|
for threadId, stack in sys._current_frames().items():
|
2017-09-25 16:24:35 +01:00
|
|
|
worker.log.error(''.join(traceback.format_stack(stack)))
|
2017-10-12 11:38:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_exit(server):
|
|
|
|
|
server.log.info("Stopping Notifications API")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def worker_int(worker):
|
|
|
|
|
worker.log.info("worker: received SIGINT {}".format(worker.pid))
|