2

just started on using web.py and heroku, so...

I have this simple app that I want to upload to heroku and I have followed the instruction from http://joshuaoiknine.com/post/47196802362/publishing-for-the-web-py-python-framework-to-heroku

This is my Procfile:

web: python code.py $PATH

But after I uploaded it to heroku, it gives me the application error. The heroku log shows me this:

2013-08-08T03:27:44.956675+00:00 heroku[web.1]: Starting process with command `python code.py /usr/local/bin:/usr/bin:/bin`
2013-08-08T03:27:45.673358+00:00 app[web.1]: Traceback (most recent call last):
2013-08-08T03:27:45.673358+00:00 app[web.1]:   File "code.py", line 52, in <module>
2013-08-08T03:27:45.673358+00:00 app[web.1]:     app.run()
2013-08-08T03:27:45.673358+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/web/application.py", line 313, in run
2013-08-08T03:27:45.673358+00:00 app[web.1]:     return wsgi.runwsgi(self.wsgifunc(*middleware))
2013-08-08T03:27:45.673358+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/web/wsgi.py", line 54, in runwsgi
2013-08-08T03:27:45.673358+00:00 app[web.1]:     return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
2013-08-08T03:27:45.673358+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/web/net.py", line 76, in validip
2013-08-08T03:27:45.673358+00:00 app[web.1]:     port = int(port)
2013-08-08T03:27:45.673552+00:00 app[web.1]: ValueError: invalid literal for int() with base 10: '/usr/local/bin:/usr/bin:/bin'
2013-08-08T03:27:46.866238+00:00 heroku[web.1]: Process exited with status 1
2013-08-08T03:27:46.881655+00:00 heroku[web.1]: State changed from starting to crashed

However, when i tried the second method, I receive this error:

Traceback (most recent call last):
  File "code.py", line 55, in <module>
    app.run(host='0.0.0.0', port=port)
TypeError: run() got an unexpected keyword argument 'host'

Any ideas how to get my app onto heroku up and running?

4

1 回答 1

1

code.py首先需要一个整数参数,而不是你的 $PATH。它可能是它所期望的端口,因此而不是$PATH在您的Procfilepass$PORT中。

更好的是:更改要使用的代码ENV["PORT"],如果未定义(在您的本地开发环境中可能是这种情况),则使用默认值(例如,您的开发环境为 8000 或 8080)。

在 Heroku 上,您的服务器需要监听的端口不是固定的——它会随着每次 dyno 的每次重启而改变。Heroku 会设置环境变量PORT,让你知道监听哪个端口。

于 2013-08-11T06:39:53.250 回答