gunicorn on heruko binding to localhost, without messing up deployment to heruko

对着背影说爱祢 提交于 2019-12-24 16:05:11

问题


This is a spin off question from gunicorn on heroku: binding to localhost.

How can I get gunicorn to work both locally (using foreman) and for deployment on Heroku?

Procfile contains:

web: gunicorn mysite.wsgi

When I deploy locally using foreman, gunicorn binds to http://0.0.0.0:5000. I want it to bind to 127.0.0.1:8000. However, if I change to the Procfile to this:

web: gunicorn -b 127.0.0.1:8000 mysite.wsgi

Then I can't deploy to Heroku, the browser will return "application error"

$ heroku ps
=== web (1X): `gunicorn -b 127.0.0.1:8000 mysite.wsgi`
web.1: crashed 2013/08/22 23:45:04 (~ 1m ago)

Where is the default binding address set and/or what gunicorn options do I put in Procfile to get it to work on 127.0.0.1? What could be unique to my situation that causes a deviant default setup (I'm working in mac OS - lion, maybe?)


回答1:


Dont bind gunicorn to the local ip with. web: gunicorn -b 127.0.0.1:8000 mysite.wsgi in your procfile. This forces your django app to always use this local port whether or not its deployed locally or on Heroku's servers.

Using

web: gunicorn mysite.wsgi

in your procfile will make your application deploy at 127.0.0.1:8000 locally and 0.0.0.0:5000 on heroku's severs. I know you had to use the bind method in your previous question to get heroku to work locally, but that method is only covering an issue that isn't resolved.

Using foreman start with web: gunicorn mysite.wsgi should work, as told by the official docs (and my own experince :)).

Try just web: gunicorn mysite.wsgi in your procfile, deploy it to heroku and see if it works.

https://devcenter.heroku.com/articles/python



来源:https://stackoverflow.com/questions/18433550/gunicorn-on-heruko-binding-to-localhost-without-messing-up-deployment-to-heruko

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!