我正在创建一个简单的flaskapp,然后将其部署在heroku上,这是第一次在heroku上部署python应用程序,说我对gunicorn并不陌生。
其他说明:使用虚拟环境。
烧瓶的版本Flask == 0.10.1
gunicorn == 19.3.0
使用’python run.py’ 工作
使用“开工开始”会出现以下错误
16:35:44 web.1 | started with pid 4047
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Starting gunicorn 19.3.0
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Listening at: http://0.0.0.0:5000 (4047)
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Using worker: sync
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4053] [INFO] Booting worker with pid: 4053
16:35:44 web.1 | * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4053] [ERROR] Exception in worker process:
16:35:44 web.1 | Traceback (most recent call last):
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
16:35:44 web.1 | worker.init_process()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
16:35:44 web.1 | self.wsgi = self.app.wsgi()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
16:35:44 web.1 | self.callable = self.load()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
16:35:44 web.1 | return self.load_wsgiapp()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
16:35:44 web.1 | return util.import_app(self.app_uri)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
16:35:44 web.1 | __import__(module)
16:35:44 web.1 | File "/home/adminuser/Desktop/Github/SoftwareEng/barcodeServer/SoftwareEng/run.py", line 3, in <module>
16:35:44 web.1 | flaskapp.run(debug=True)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/flask/app.py", line 772, in run
16:35:44 web.1 | run_simple(host, port, self, **options)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/werkzeug/serving.py", line 617, in run_simple
16:35:44 web.1 | test_socket.bind((hostname, port))
16:35:44 web.1 | File "/usr/lib/python2.7/socket.py", line 224, in meth
16:35:44 web.1 | return getattr(self._sock,name)(*args)
16:35:44 web.1 | error: [Errno 98] Address already in use
16:35:44 web.1 | Traceback (most recent call last):
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
16:35:44 web.1 | worker.init_process()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
16:35:44 web.1 | self.wsgi = self.app.wsgi()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
16:35:44 web.1 | self.callable = self.load()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
16:35:44 web.1 | return self.load_wsgiapp()
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
16:35:44 web.1 | return util.import_app(self.app_uri)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
16:35:44 web.1 | __import__(module)
16:35:44 web.1 | File "/home/adminuser/Desktop/Github/SoftwareEng/barcodeServer/SoftwareEng/run.py", line 3, in <module>
16:35:44 web.1 | flaskapp.run(debug=True)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/flask/app.py", line 772, in run
16:35:44 web.1 | run_simple(host, port, self, **options)
16:35:44 web.1 | File "/home/adminuser/Desktop/test/SoftwareEng/local/lib/python2.7/site-packages/werkzeug/serving.py", line 617, in run_simple
16:35:44 web.1 | test_socket.bind((hostname, port))
16:35:44 web.1 | File "/usr/lib/python2.7/socket.py", line 224, in meth
16:35:44 web.1 | return getattr(self._sock,name)(*args)
16:35:44 web.1 | error: [Errno 98] Address already in use
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4053] [INFO] Worker exiting (pid: 4053)
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Shutting down: Master
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Reason: Worker failed to boot.
16:35:44 web.1 | exited with code 3
16:35:44 system | sending SIGTERM to all processes
程序文件
web: gunicorn run:flaskapp --log-file=-
档案结构
/
...
run.py
Procfile
app/
__init__.py
routes.py
...
运行
from app import flaskapp
flaskapp.run(debug=True)
init.py
from flask import Flask
flaskapp = Flask(__name__)
from app import routes
route.py
from app import flaskapp
from flask import render_template
import dbwrapper
@flaskapp.route('/')
@flaskapp.route('/home')
def index():
return render_template('home.html')
从我的理解中,gunicorn允许创建多个线程,这使我认为线程正在尝试访问同一端口,这会引发已经使用的错误。但是我不知道如何解决它,任何帮助表示赞赏。
看起来你在调用run:flaskapp而不是app:flaskapp,而run.py试图打开另一个实例。
16:35:44 web.1 | File "/home/adminuser/Desktop/Github/SoftwareEng/barcodeServer/SoftwareEng/run.py", line 3, in <module>
首先,始终封装运行:
if __name__ == '__main__':
flaskapp.run(debug=True)
并更新你的procfile来调用app.__init__.py
代替:
web: gunicorn app:flaskapp --log-file=-
PS:我不知道什么是procfile或领班-heroku的东西?
问题内容: 当我在Docker项目中运行时,它失败并显示以下消息: 显示如下: 我已经尝试过了,但是没有帮助。 问题答案: 在您的情况下,使用该端口的是其他一些过程,如注释中所述,它帮助您解决了问题。 在其他情况下(我本人也曾多次遇到),它大多是在其他情况下运行的同一容器。在那种情况下非常有帮助,因为我经常让相同的容器在其他目录中运行,然后尝试在其他使用相同容器名称的地方再次运行。 如何为我提供帮
我有一个测试应用程序,我创建了一个测试应用程序,用于开始使用Eclipse学习weblogic。昨天,当我作为/在服务器上运行时,jsp页面运行良好,我得到了我创建的基本页面。但今天我有一条错误消息: 本机方法中的致命错误:JDWP没有初始化传输,jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)错误:传输错误202:绑定失败:地址已在使用错误:JDWP传输dt_
这是一个已知的错误还是我做得不对?
问题内容: 在Eclipse中,出现此错误: 我不知道为什么现在出现,但几个小时前就可以运行了。我需要重启机器吗?我如何深入了解它?我感谢任何提示或建议。 问题答案: 是的,你有另一个绑定到同一端口的进程。 每当我遇到JVM_BIND错误时,Windows Sysinternals的TCPView(仅Windows)都是我最喜欢的应用程序。它显示了哪些进程正在侦听哪个端口。它还提供了一个方便的上下
问题内容: 我正在尝试使用启动多个docker容器,但出现以下(部分)错误消息: 按照https://github.com/docker/docker/issues/8714的建议,我尝试了命令 导致 但是,我在这里看不到任何可以杀死的进程ID。任何想法是什么导致此错误? 问题答案: 以下https://unix.stackexchange.com/questions/106561/finding
问题内容: 运行webdriver时,运行3分钟后,出现以下异常,导致Webdriver崩溃。 我仅使用一个webdriver实例和一个FirefoxDriver配置文件。 问题答案: 您的出站端口已用完。这意味着您在两分钟之内执行了数千个出站连接。解决方案:使用连接池,或降低程序速度。