65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import os
|
|
import multiprocessing
|
|
|
|
app_path = os.path.join(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
pythonpath = app_path + '/env/'
|
|
chdir = app_path + '/src/app/'
|
|
pidfile = app_path + '/runs/gunicorn.pid'
|
|
worker_tmp_dir = app_path + '/tmp/'
|
|
tmp_upload_dir = app_path + '/tmp/'
|
|
accesslog = app_path + '/logs/gunicorn-access.log'
|
|
errorlog = app_path + '/logs/gunicorn-error.log'
|
|
|
|
daemon = False
|
|
|
|
user = 'suid'
|
|
group = 'suid'
|
|
|
|
bind = 'async.local:8181'
|
|
backlog = 2048
|
|
reload = True
|
|
worker_class = 'sanic_gunicorn.Worker'
|
|
workers = 1
|
|
# workers = multiprocessing.cpu_count() * 2 + 1
|
|
|
|
|
|
# def post_fork(server, worker):
|
|
# server.log.info("Worker spawned (pid: %s)", worker.pid)
|
|
#
|
|
#
|
|
# def pre_fork(server, worker):
|
|
# pass
|
|
#
|
|
#
|
|
# def pre_exec(server):
|
|
# server.log.info("Forked child, re-executing.")
|
|
#
|
|
#
|
|
# def when_ready(server):
|
|
# server.log.info("Server is ready. Spawning workers")
|
|
#
|
|
#
|
|
# def worker_int(worker):
|
|
# worker.log.info("worker received INT or QUIT signal")
|
|
#
|
|
# # get traceback info
|
|
# import threading, sys, traceback
|
|
# id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
|
|
# code = []
|
|
# for threadId, stack in sys._current_frames().items():
|
|
# code.append('\n# Thread: {}({})'.format(id2name.get(threadId, ""), threadId))
|
|
# for filename, lineno, name, line in traceback.extract_stack(stack):
|
|
# code.append('File: "{}", line {}, in {}'.format(filename, lineno, name))
|
|
# if line:
|
|
# code.append('{}'.format(line.strip()))
|
|
# worker.log.debug("\n".join(code))
|
|
|
|
|
|
def worker_abort(worker):
|
|
worker.log.info("worker received SIGABRT signal")
|
|
|
|
|
|
# if __name__ == '__main__':
|
|
# print(os.path.join(os.path.dirname(os.path.abspath(__file__))))
|