在调试模式下运行时,为什么Flask在我的Docker-Compose-Project内部崩溃?

时间:2019-06-20 15:33:33

标签: python docker flask docker-compose werkzeug

我正在flask项目中以debug模式运行docker-compose网络服务器。加载第一页后,服务器将崩溃,并陷入无限加载中。

由于某种原因,它以前可以工作(优秀的老软件工程师发行了...)。然后我的同事告诉我,在他设置好它后,它对他不起作用。我测试了之前的版本,该版本可以正常工作,但后来决定再次从存储库中提取并重建项目。之后,我和他有同样的问题(即使根据git,我的存储库与GitHub上的存储库相同)。

该项目针对Python和Flask运行以下版本(由于我们必须使用某些软件包):

Python版本:2.7
烧瓶版本:0.11.1

这是我的runserver.py中启动服务器的代码。

#!/usr/bin/env python

# This file starts the WSGI web application.
# - Heroku starts gunicorn, which loads Procfile, which starts runserver.py
# - Developers can run it from the command line: python runserver.py


from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer

from webrob.app_and_db import app, db
from webrob.pages.meshes import update_meshes
from webrob.startup.init_app import init_app


def _config_is_debug():
    # if environment variable 'EASE_DEBUG' is set to true, then
    # 'DEBUG' in app.config will be set to true by init_app.py
    return 'DEBUG' in app.config and app.config['DEBUG']


def _run_debug_server():
    print 'Run web server in DEBUG mode'
    app.run(host='0.0.0.0', debug=True, threaded=False)


def _run_server():
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(5000)
    print 'Web server is running. Listening on {}'.format(5000)
    IOLoop.instance().start()


init_app(app, db)

# Start a development web server if executed from the command line
if __name__ == '__main__':
    update_meshes()
    if _config_is_debug():
        _run_debug_server()
    else:
        _run_server()

注意:启动普通服务器后,项目将正常运行(可以通过将EASE-DEBUG内的docker-compose设置为false来完成)。

该项目是开源的,因此所有其他文件都可以在https://github.com/navidJadid/openease_webserver_development(可能在git-子模块内)中找到。不幸的是,到目前为止,整个项目必须要能够正常工作(我目前正在将其从当前状态重构)。设置有点麻烦,但是在提供的存储库的README.md中进行了描述。

从本地主机加载第一页后,我的docker-compose日志中将出现以下错误:

[...]
* Debugger PIN: 250-565-638
openease         | 172.28.0.1 - - [20/Jun/2019 14:57:14] "GET /user/forgot-password HTTP/1.1" 200 -
openease         | 172.28.0.1 - - [20/Jun/2019 14:57:15] "POST /knowrob/menu HTTP/1.1" 200 -
openease         | 172.28.0.1 - - [20/Jun/2019 14:57:15] "GET /static/css/oe-logo.svg HTTP/1.1" 404 -
openease         | 172.28.0.1 - - [20/Jun/2019 14:57:15] "GET /static/HowtouseopenEASE.mp4 HTTP/1.1" 200 -
openease         | Exception in thread Thread-2:
openease         | Traceback (most recent call last):
openease         |   File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
openease         |     self.run()
openease         |   File "/usr/lib/python2.7/threading.py", line 754, in run
openease         |     self.__target(*self.__args, **self.__kwargs)
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 966, in inner
openease         |     srv.serve_forever()
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 734, in serve_forever
openease         |     HTTPServer.serve_forever(self)
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 233, in serve_forever
openease         |     self._handle_request_noblock()
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 292, in _handle_request_noblock
openease         |     self.handle_error(request, client_address)
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
openease         |     self.process_request(request, client_address)
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
openease         |     self.finish_request(request, client_address)
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
openease         |     self.RequestHandlerClass(request, client_address, self)
openease         |   File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
openease         |     self.handle()
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 326, in handle
openease         |     rv = BaseHTTPRequestHandler.handle(self)
openease         |   File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
openease         |     self.handle_one_request()
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 361, in handle_one_request
openease         |     return self.run_wsgi()
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 303, in run_wsgi
openease         |     execute(self.server.app)
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 294, in execute
openease         |     write(data)
openease         |   File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 275, in write
openease         |     self.wfile.write(data)
openease         | IOError: [Errno 32] Broken pipe

我需要服务器以debug模式运行,因为我需要对源文件进行更改,而不必每次都重新启动或重建docker容器,因为这只会花费太多时间。但是正如我提到的那样,到目前为止,加载第一页后它会崩溃。以前它还在工作,这让我感到困惑。

我尝试运行具有自动重装功能的tornado服务器,但该服务器也不起作用。另外,我尝试将threading参数设置为True,但没有成功。

预先感谢〜

0 个答案:

没有答案