我正在尝试使用Gunicorn服务于烧瓶应用。当我使用来启动应用程序时,thp复制可以正常工作
python3 wsgi.py
我在做gunicorn wsgi:app --bind 0.0.0.0:5000
时失败。下面是我的wsgi.py
from server import app
if __name__ == "__main__":
app.run()
请找到完整的错误消息
[2019-07-17 06:23:23 +0000] [8814] [INFO] Starting gunicorn 19.7.1
[2019-07-17 06:23:23 +0000] [8814] [INFO] Listening at: http://0.0.0.0:5000 (8814)
[2019-07-17 06:23:23 +0000] [8814] [INFO] Using worker: sync
[2019-07-17 06:23:23 +0000] [8818] [INFO] Booting worker with pid: 8818
[2019-07-17 06:23:23 +0000] [8818] [ERROR] invalid syntax (server.py, line 117)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 377, in import_app
__import__(module)
File "/home/project/backend/wsgi.py", line 1, in <module>
from server import app
File "/home/ project /backend/server.py", line 117
fields_to_query = { **fields_to_query, **provider_query }
^
SyntaxError: invalid syntax
[2019-07-17 06:23:23 +0000] [8818] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 148, in load_wsgi
self.reloader.add_extra_file(exc_val.filename)
AttributeError: 'NoneType' object has no attribute 'add_extra_file'
[2019-07-17 06:23:23 +0000] [8818] [INFO] Worker exiting (pid: 8818)
[2019-07-17 06:23:23 +0000] [8814] [INFO] Shutting down: Master
[2019-07-17 06:23:23 +0000] [8814] [INFO] Reason: Worker failed to boot.
答案 0 :(得分:0)
您似乎正在使用python3:
File "/home/ project /backend/server.py", line 117
fields_to_query = { **fields_to_query, **provider_query }
^
SyntaxError: invalid syntax
但是您的gunicorn现在是python2,这就是为什么它会产生无效的语法错误
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py"