正在运行
gunicorn -c gunicorn_config.py mainDAL:app
gunicorn_config.py:
worker_class = 'sync'
worker_connections = 1000
timeout = 960
keepalive = 2
#This is the nuclear option. will print everything to log
spew = False
daemon = False
pidfile = "master.pid"
umask = 0
user = None
group = None
tmp_upload_dir = None
logfile = 'log_tmp.log'
errorlog = 'temp_error_log.log'
loglevel = 'info'
accesslog = 'temp_access_log.log'
proc_name = 'DAL'
# 0 is unlimited
limit_request_line = 0
def worker_exit(server, worker):
error_stack_trace = repr(traceback.format_exc())
if is_known_error(error_stack_trace):
os.system('kill -TTIN `cat master.pid`')
print "Worker worker_exit"
message = 'test_gunicorn_worker_exit ' + error_stack_trace
logger.error(message)
sentry_client.captureMessage(message)
file = open(str(worker.pid) + '.closed', 'w+')
file.close()
我的应用程序有时会崩溃。我没有看到并记录worker_exit
编辑:
我发现worker_exit
正在打印
ImportError: No module named bcrypt
我发现这个pip不存在于虚拟环境之外。 问题是
1. why does the gunicorn auto restart without a a restart signal `kill -HUP`
2. why does the restart thread runs outside of the virtualenv while the the first time runs inside the virtualenv.
我甚至在虚拟环境之外运行pip freeze |grep bcrypt
,而pip就在那里。
所以我想我的问题是要理解为什么gunicorn
找不到这个点?