I have a gunicorn
server running with 1 worker. I user the logging module during the request. None of them appear in stdout.
I know that gevent workers monkey patch all so I would assume any loggin done during the request should appear on the mainthread stdout.
The app parse to gunicorn is the application wsgi from django.
gunicorn -c gunicorn.py core.wsgi:application
In gunicorn.py
I have:
bind = '0.0.0.0:8080'
backlog = 2048
workers = 1
worker_class = 'gevent'
worker_connections = 1000
timeout = 60
keepalive = 2
proc_name = None
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")
import threading, sys, traceback
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
code = []
for thread_id, stack in sys._current_frames().items():
code.append("\n# Thread: %s(%d)" % (id2name.get(thread_id, ""),
thread_id))
for filename, line_no, name, line in traceback.extract_stack(stack):
code.append('File: "%s", line %d, in %s' % (filename,
line_no, name))
if line:
code.append(" %s" % (line.strip()))
worker.log.debug("\n".join(code))
def worker_abort(worker):
worker.log.info("Worker received SIGABRT signal")
Within on of the request functions I simply put
import logging
logging.error('test'))
It only executes this log after the worker has finished its request. And some of the other logs don't even show up like so.
import logging
logger = logging.getLogger('test_logger'))
logger.setLevel(logging.DEBUG)
logger.error('test')
If you need anything else from me to possibly help me towards resolving this issue ask away.
Simply needed to add this to the gunicorn.py