我在烧瓶应用程序正在与结构的基础上http://code.tutsplus.com/tutorials/an-introduction-to-pythons-flask-framework--net-28822截图烧瓶中。为了在本地工作,我一直在运行routes.py文件。
我现在正试图在heroku上部署使用gunicorn后跟https://www.udacity.com/wiki/ud330/deploy。继方向,我requirements.txt包含:
$ pip Freeze
Flask==0.10.1
Flask-Mail==0.9.1
Flask-SQLAlchemy==2.1
Flask-WTF==0.12
Jinja2==2.8
MarkupSafe==0.23
SQLAlchemy==1.0.11
WTForms==2.1
Werkzeug==0.11.3
blinker==1.4
gunicorn==19.4.5
itsdangerous==0.24
我不知道该怎么把我的Procfile,我试过几个变化,包括:
但我得到按照Heroku的日志:
←[32m2016-01-23T17:15:39.572265+00:00 app[web.1]:←[0m ImportError: No module named mi
ni
←[32m2016-01-23T17:15:39.652562+00:00 app[web.1]:←[0m super(Application, self).ru
n()
←[32m2016-01-23T17:15:39.652583+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
←[32m2016-01-23T17:15:39.652835+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 347, in stop
←[32m2016-01-23T17:15:39.572260+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
←[32m2016-01-23T17:15:39.652807+00:00 app[web.1]:←[0m self.stop()
←[32m2016-01-23T17:15:39.652914+00:00 app[web.1]:←[0m time.sleep(0.1)
←[32m2016-01-23T17:15:39.653207+00:00 app[web.1]:←[0m gunicorn.errors.HaltServer: <Ha
ltServer 'Worker failed to boot.' 3>
←[32m2016-01-23T17:15:40.600197+00:00 heroku[web.1]:←[0m State changed from starting
to crashed
←[32m2016-01-23T17:15:40.576720+00:00 heroku[web.1]:←[0m Process exited with status 1
而且我runserver.py文件包含:
from intro_to_flask import app
app.run(debug=True)
我该如何解决这个问题?
编辑改变Procfile到:
web: gunicorn runserver:app
现在越来越:
←[32m2016-01-23T17:47:43.545434+00:00 app[web.1]:←[0m from intro_to_flask import
app
←[32m2016-01-23T17:47:43.545435+00:00 app[web.1]:←[0m ImportError: No module named in
tro_to_flask
←[32m2016-01-23T17:47:43.545435+00:00 app[web.1]:←[0m Traceback (most recent call las
t):
←[32m2016-01-23T17:47:43.545436+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
←[32m2016-01-23T17:47:43.545438+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
←[32m2016-01-23T17:47:43.545437+00:00 app[web.1]:←[0m worker.init_process()
←[32m2016-01-23T17:47:43.545438+00:00 app[web.1]:←[0m self.load_wsgi()
←[32m2016-01-23T17:47:43.545439+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
←[32m2016-01-23T17:47:43.545440+00:00 app[web.1]:←[0m self.wsgi = self.app.wsgi()
←[32m2016-01-23T17:47:43.545440+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
←[32m2016-01-23T17:47:43.545441+00:00 app[web.1]:←[0m self.callable = self.load()
←[32m2016-01-23T17:47:43.545442+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
←[32m2016-01-23T17:47:43.545442+00:00 app[web.1]:←[0m return self.load_wsgiapp()
←[32m2016-01-23T17:47:43.545443+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
←[32m2016-01-23T17:47:43.545444+00:00 app[web.1]:←[0m return util.import_app(self
EDIT2:
作出改变,以一个正常的 '__init__.py'。 intro_to_flask现在注册为一个模块:
←[36m2016-01-23T18:15:18.071418+00:00 app[web.1]:←[0m from intro_to_flask import
app
←[36m2016-01-23T18:15:18.150803+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
←[36m2016-01-23T18:15:18.150846+00:00 app[web.1]:←[0m WSGIApplication("%(prog)s [
OPTIONS] [APP_MODULE]").run()
←[36m2016-01-23T18:15:18.071419+00:00 app[web.1]:←[0m ImportError: cannot import name
app
←[36m2016-01-23T18:15:18.071605+00:00 app[web.1]:←[0m [2016-01-23 18:15:18 +0000] [10
] [INFO] Worker exiting (pid: 10)
←[36m2016-01-23T18:15:18.150976+00:00 app[web.1]:←[0m Arbiter(self).run()
←[36m2016-01-23T18:15:18.150712+00:00 app[web.1]:←[0m Traceback (most recent call las
t):
←[36m2016-01-23T18:15:18.151078+00:00 app[web.1]:←[0m self.halt(reason=inst.reaso
n, exit_status=inst.exit_status)
←[36m2016-01-23T18:15:18.150718+00:00 app[web.1]:←[0m File "/app/.heroku/python/bin
/gunicorn", line 11, in <module>
←[36m2016-01-23T18:15:18.151098+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 302, in halt
←[36m2016-01-23T18:15:18.150773+00:00 app[web.1]:←[0m sys.exit(run())
←[36m2016-01-23T18:15:18.151169+00:00 app[web.1]:←[0m self.stop()
←[36m2016-01-23T18:15:18.151172+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 347, in stop
←[36m2016-01-23T18:15:18.151267+00:00 app[web.1]:←[0m time.sleep(0.1)
←[36m2016-01-23T18:15:18.150869+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
←[36m2016-01-23T18:15:18.151289+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
←[36m2016-01-23T18:15:18.150923+00:00 app[web.1]:←[0m super(Application, self).ru
n()
←[36m2016-01-23T18:15:18.151342+00:00 app[web.1]:←[0m self.reap_workers()
←[36m2016-01-23T18:15:18.150943+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
←[36m2016-01-23T18:15:18.151362+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
←[36m2016-01-23T18:15:18.150998+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/gunicorn/arbiter.py", line 206, in run
←[36m2016-01-23T18:15:18.151520+00:00 app[web.1]:←[0m gunicorn.errors.HaltServer: <Ha
ltServer 'Worker failed to boot.' 3>
←[36m2016-01-23T18:15:18.151455+00:00 app[web.1]:←[0m raise HaltServer(reason, se
lf.WORKER_BOOT_ERROR)
←[36m2016-01-23T18:15:19.049307+00:00 heroku[web.1]:←[0m Process exited with status 1
←[36m2016-01-23T18:15:19.061843+00:00 heroku[web.1]:←[0m State changed from starting
to crashed
编辑3:
←[36m2016-01-23T19:14:56.910512+00:00 app[web.1]:←[0m from intro_to_flask import
routes
←[36m2016-01-23T19:14:56.910513+00:00 app[web.1]:←[0m File "/app/intro_to_flask/rou
tes.py", line 123, in <module>
←[36m2016-01-23T19:14:56.910513+00:00 app[web.1]:←[0m app.run()
←[36m2016-01-23T19:14:56.910514+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/flask/app.py", line 772, in run
←[36m2016-01-23T19:14:56.910515+00:00 app[web.1]:←[0m run_simple(host, port, self
, **options)
←[36m2016-01-23T19:14:56.910515+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 692, in run_simple
←[36m2016-01-23T19:14:56.910516+00:00 app[web.1]:←[0m inner()
←[36m2016-01-23T19:14:56.910516+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 654, in inner
←[36m2016-01-23T19:14:56.910517+00:00 app[web.1]:←[0m fd=fd)
←[36m2016-01-23T19:14:56.910518+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 548, in make_server
←[36m2016-01-23T19:14:56.910518+00:00 app[web.1]:←[0m passthrough_errors, ssl_con
text, fd=fd)
←[36m2016-01-23T19:14:56.910519+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 462, in __init__
←[36m2016-01-23T19:14:56.910523+00:00 app[web.1]:←[0m HTTPServer.__init__(self, (
host, int(port)), handler)
←[36m2016-01-23T19:14:56.910524+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/SocketServer.py", line 420, in __init__
←[36m2016-01-23T19:14:56.910525+00:00 app[web.1]:←[0m self.server_bind()
←[36m2016-01-23T19:14:56.910526+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/BaseHTTPServer.py", line 108, in server_bind
←[36m2016-01-23T19:14:56.910526+00:00 app[web.1]:←[0m SocketServer.TCPServer.serv
er_bind(self)
←[36m2016-01-23T19:14:56.910527+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/SocketServer.py", line 434, in server_bind
←[36m2016-01-23T19:14:56.910528+00:00 app[web.1]:←[0m self.socket.bind(self.serve
r_address)
←[36m2016-01-23T19:14:56.910529+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/socket.py", line 228, in meth
←[36m2016-01-23T19:14:56.910529+00:00 app[web.1]:←[0m return getattr(self._sock,n
ame)(*args)
←[36m2016-01-23T19:14:56.910548+00:00 app[web.1]:←[0m error: [Errno 98] Address alrea
dy in use
←[36m2016-01-23T19:14:56.910686+00:00 app[web.1]:←[0m [2016-01-23 19:14:56 +0000] [10
] [INFO] Worker exiting (pid: 10)
←[36m2016-01-23T19:14:57.199826+00:00 heroku[web.1]:←[0m State changed from starting
to up
感谢您期待丹尼尔,请参阅编辑.. – user61629
你有一个奇怪的文件在该模块中的名称:它应该只是'__init __。py',没有'a'。 –
嗨丹尼尔,我解决了,但它仍然没有工作。请参阅编辑2. – user61629