Skip to content

Commit

Permalink
feat: add gunicorn conf
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle committed Apr 21, 2023
1 parent 3e24348 commit 8ebd8ae
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions bfportal/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
bind = "127.0.0.1:8000"
reload = True
timeout = 30
errorlog = "-"
loglevel = "info"
wsgi_app = "bfportal.wsgi:application"


def when_ready(server):
"""Called just after the master process is initialized."""
server.log.info("Server is ready. Spawning workers")


def worker_int(worker):
"""Called when a worker receives the INT or QUIT signal."""
worker.log.info("worker received INT or QUIT signal")

# get traceback info
import sys
import threading
import traceback

id2name = {th.ident: th.name for th in threading.enumerate()}
code = []
for threadId, stack in sys._current_frames().items():
code.append("\n# Thread: %s(%d)" % (id2name.get(threadId, ""), threadId))
for filename, lineno, name, line in traceback.extract_stack(stack):
code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
if line:
code.append(" %s" % (line.strip()))
worker.log.debug("\n".join(code))


def worker_abort(worker):
"""Called when a worker receives the SIGABRT signal."""
worker.log.info("worker received SIGABRT signal")


print("Gunicorn config loaded")

0 comments on commit 8ebd8ae

Please sign in to comment.