问候和问候,
我正在尝试使用 gunicorn+nginx 和主管让我的 Flask 应用程序在我的 Ubuntu VPS 上运行。当我通过 ssh 登录到我的 vps 时,一切正常。当我注销时,我得到一个错误的网关。
gunicorn 错误日志给了我:
Traceback (most recent call last):
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 131, in handle_request
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 144, in __call__
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/flask/app.py", line 1407, in handle_exception
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/flask/app.py", line 1420, in log_exception
File "/home/michael/dev/myapp/env/local/lib/python2.7/site-packages/flask/app.py", line 582, in logger
ImportError: No module named logging
这对我来说真的很奇怪。Flask 使用 python 自己的日志记录模块。我可以在 python shell 中导入模块。我还在 virtualenv 中运行所有内容。
作为参考,我的supervisor.conf:
[program:gunicorn]
directory = /home/michael/dev/myapp
user=michael
command = /home/michael/dev/myapp/env/bin/gunicorn mpn:app
directory = /home/michael/dev/myapp
environment=PATH="/home/michael/dev/myapp/env/bin"
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile = /home/michael/dev/myapp/logs/supervisor.log
stderr_logfile = /home/michael/dev/myapp/logs/supervisor_error.log
我希望有一个人可以帮助我。我花了太多时间 stackover-google-maillist-ing 这个。
编辑:
我切换到 Debian,这个问题不再发生,尽管我仍然对解决方案感到好奇。