【发布时间】:2014-04-04 12:34:53
【问题描述】:
我正在尝试在我的机器上设置一个 lastuser OAuth 服务器。所以我打算用 SSL(在 443 上)和lastuser 应用程序设置 Nginx 作为 WSGI 服务器。
我有setup HTTPS/SSL with Nginx,它在我的机器上运行良好。
但是 WSGI 服务器不工作。
Lastuser 基本上是一个带有 WSGI 脚本 website.wsgi 的 Flask 应用程序。
import sys
import os.path
sys.path.insert(0, os.path.dirname(__file__))
from lastuserapp import app as application, init_for
init_for('production')
我尝试将 gunicorn 用于 WSGI,但收到错误 ImportError: No module named wsgi,如下所示:
$ gunicorn -b localhost:7000 website.wsgi
2014-03-03 17:06:49 [31267] [INFO] Starting gunicorn 0.13.4
2014-03-03 17:06:49 [31267] [INFO] Listening at: http://127.0.0.1:7000 (31267)
2014-03-03 17:06:49 [31267] [INFO] Using worker: sync
2014-03-03 17:06:49 [31270] [INFO] Booting worker with pid: 31270
2014-03-03 17:06:50 [31270] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/gunicorn/arbiter.py", line 456, in spawn_worker
worker.init_process()
File "/usr/lib/pymodules/python2.7/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/usr/lib/pymodules/python2.7/gunicorn/app/base.py", line 101, in wsgi
self.callable = self.load()
File "/usr/lib/pymodules/python2.7/gunicorn/app/wsgiapp.py", line 24, in load
return util.import_app(self.app_uri)
File "/usr/lib/pymodules/python2.7/gunicorn/util.py", line 241, in import_app
__import__(module)
ImportError: No module named wsgi
2014-03-03 17:06:50 [31270] [INFO] Worker exiting (pid: 31270)
2014-03-03 17:06:50 [31267] [INFO] Shutting down: Master
2014-03-03 17:06:50 [31267] [INFO] Reason: Worker failed to boot.
所以我的问题是:我做错了什么还是 gnunicorn 或我机器上安装的库有问题?
【问题讨论】:
标签: python nginx flask wsgi gunicorn