0

昨天我完成了 Heroku 开发中心教程,以便在 Heroku 上开始使用 Django。使用该教程,我创建了一个名为“oldtestapp”的应用程序......

今天我去了heroku.com,登录并删除了oldtestapp。我有一个想要迁移到 Heroku 的现有 Django 项目。我将 Procfile 和 requirements.txt 从 oldtestapp 复制到我的新应用程序的根目录(与 manage.py 所在的目录相同)。我更改了 Procfile:它说“oldtestapp.wsgi”我将它更改为“newapp.wsgi”,其中 newapp 是我的 Django 应用程序的名称。我在该项目的根目录中打开了 git bash(与 manage.py 相同的目录)并成功地将所有内容推送到 git 和 heroku。

当我这样做时,我得到了一个内部服务器错误heroku open。日志如下(我用 emailaddress@email.com 替换了我的电子邮件):

$ heroku logs
2013-07-17T23:09:55+00:00 heroku[slug-compiler]: Slug compilation started
2013-07-17T23:09:56+00:00 heroku[slug-compiler]: Slug compilation failed: no Ced
ar-supported app detected
2013-07-17T23:15:43+00:00 heroku[slug-compiler]: Slug compilation started
←[36m2013-07-17T23:17:07.691491+00:00 heroku[api]:←[0m Scale to web=1 by emailadd
ress@email.com
←[36m2013-07-17T23:17:07.728257+00:00 heroku[api]:←[0m Deploy e6cec10 by emailadd
ress@email.com
←[36m2013-07-17T23:17:07.775009+00:00 heroku[api]:←[0m Release v3 created by emailaddress@email.com
←[36m2013-07-17T23:17:07.812132+00:00 heroku[api]:←[0m Deploy e6cec10 by emailadd
ress@email.com
2013-07-17T23:17:08+00:00 heroku[slug-compiler]: Slug compilation finished
←[33m2013-07-17T23:17:15.119247+00:00 heroku[web.1]:←[0m Starting process with c
ommand `gunicorn oldtestapp.wsgi`
←[33m2013-07-17T23:17:17.533626+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [2] [I
NFO] Listening at: http://0.0.0.0:43432 (2)
←[33m2013-07-17T23:17:17.535035+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [2] [I
NFO] Using worker: sync
←[33m2013-07-17T23:17:17.531496+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [2] [I
NFO] Starting gunicorn 17.5
←[33m2013-07-17T23:17:17.567349+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [7] [I
NFO] Booting worker with pid: 7
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in spawn_worker
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m     worker.init_process()
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m     self.wsgi = self.app.w
sgi()
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [7] [E
RROR] Exception in worker process:
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m Traceback (most recent cal
l last):
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_proce
ss
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/base.py", line 115, in wsgi
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m ImportError: No module nam
ed oldtestapp.wsgi
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in spawn_worker
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m     __import__(module)
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m Traceback (most recent cal
l last):
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 33, in load
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m     return util.import_app
(self.app_uri)
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/util.py", line 353, in import_app
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/base.py", line 115, in wsgi
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_proce
ss
←[33m2013-07-17T23:17:17.618566+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/util.py", line 353, in import_app
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m     self.callable = self.l
oad()
←[33m2013-07-17T23:17:17.618566+00:00 app[web.1]:←[0m     return util.import_app
(self.app_uri)
←[33m2013-07-17T23:17:17.618566+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 33, in load
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m     worker.init_process()
←[33m2013-07-17T23:17:17.618202+00:00 app[web.1]:←[0m     self.callable = self.l
oad()
←[33m2013-07-17T23:17:17.620526+00:00 app[web.1]:←[0m 2013-07-17 23:17:17 [7] [I
NFO] Worker exiting (pid: 7)
←[33m2013-07-17T23:17:17.618566+00:00 app[web.1]:←[0m     __import__(module)
←[33m2013-07-17T23:17:17.618566+00:00 app[web.1]:←[0m ImportError: No module nam
ed oldtestapp.wsgi
←[33m2013-07-17T23:17:17.618410+00:00 app[web.1]:←[0m     self.wsgi = self.app.w
sgi()
←[33m2013-07-17T23:17:17.699855+00:00 heroku[web.1]:←[0m State changed from star
ting to up
←[33m2013-07-17T23:17:18.100018+00:00 app[web.1]:←[0m 2013-07-17 23:17:18 [2] [I
NFO] Shutting down: Master
←[33m2013-07-17T23:17:18.104067+00:00 app[web.1]:←[0m 2013-07-17 23:17:18 [2] [I
NFO] Reason: Worker failed to boot.
←[33m2013-07-17T23:17:19.804175+00:00 heroku[web.1]:←[0m Process exited with sta
tus 3
←[33m2013-07-17T23:17:24.727149+00:00 heroku[web.1]:←[0m Starting process with c
ommand `gunicorn oldtestapp.wsgi`
←[33m2013-07-17T23:17:25.684787+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [2] [I
NFO] Starting gunicorn 17.5
←[33m2013-07-17T23:17:25.685477+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [2] [I
NFO] Listening at: http://0.0.0.0:10242 (2)
←[33m2013-07-17T23:17:25.689543+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [2] [I
NFO] Using worker: sync
←[33m2013-07-17T23:17:25.698842+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [7] [I
NFO] Booting worker with pid: 7
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [7] [E
RROR] Exception in worker process:
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in spawn_worker
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/base.py", line 115, in wsgi
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m     worker.init_process()
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m     __import__(module)
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m     self.callable = self.l
oad()
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_proce
ss
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in spawn_worker
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m     return util.import_app
(self.app_uri)
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m Traceback (most recent cal
l last):
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m     self.wsgi = self.app.w
sgi()
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m     self.callable = self.l
oad()
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m Traceback (most recent cal
l last):
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/util.py", line 353, in import_app
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 33, in load
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_proce
ss
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/base.py", line 115, in wsgi
←[33m2013-07-17T23:17:25.716897+00:00 app[web.1]:←[0m     return util.import_app
(self.app_uri)
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m     worker.init_process()
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m     __import__(module)
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/util.py", line 353, in import_app
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m     self.wsgi = self.app.w
sgi()
←[33m2013-07-17T23:17:25.717176+00:00 app[web.1]:←[0m ImportError: No module nam
ed oldtestapp.wsgi
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m ImportError: No module nam
ed oldtestapp.wsgi
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m   File "/app/.heroku/pytho
n/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 33, in load
←[33m2013-07-17T23:17:25.717331+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [7] [I
NFO] Worker exiting (pid: 7)
←[33m2013-07-17T23:17:25.863220+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [2] [I
NFO] Shutting down: Master
←[33m2013-07-17T23:17:25.863355+00:00 app[web.1]:←[0m 2013-07-17 23:17:25 [2] [I
NFO] Reason: Worker failed to boot.
←[33m2013-07-17T23:17:27.176443+00:00 heroku[web.1]:←[0m Process exited with sta
tus 3
←[33m2013-07-17T23:17:27.194233+00:00 heroku[web.1]:←[0m State changed from star
ting to crashed
←[33m2013-07-17T23:17:19.814946+00:00 heroku[web.1]:←[0m State changed from up t
o crashed
←[33m2013-07-17T23:17:19.815657+00:00 heroku[web.1]:←[0m State changed from cras
hed to starting
2013-07-17T23:19:20+00:00 heroku[slug-compiler]: Slug compilation started
←[36m2013-07-17T23:20:01.083451+00:00 heroku[api]:←[0m Deploy 339f362 by emailadd
ress@email.com
←[36m2013-07-17T23:20:01.121450+00:00 heroku[api]:←[0m Release v4 created by che
riexress@email.com
←[36m2013-07-17T23:20:01.164786+00:00 heroku[api]:←[0m Deploy 339f362 by emailadd
ress@email.com
2013-07-17T23:20:02+00:00 heroku[slug-compiler]: Slug compilation finished
←[33m2013-07-17T23:20:08.957935+00:00 heroku[web.1]:←[0m State changed from star
ting to up
←[33m2013-07-17T23:20:01.520877+00:00 heroku[web.1]:←[0m State changed from cras
hed to starting
←[36m2013-07-17T23:23:26.902944+00:00 heroku[api]:←[0m Scale to web=1 by emailadd
ress@email.com
←[32m2013-07-17T23:23:32.825464+00:00 heroku[router]:←[0m at=info method=GET pat
h=/favicon.ico host=secret-falls-6154.herokuapp.com fwd="69.249.253.220" dyno=we
b.1 connect=1ms service=4ms status=500 bytes=135
←[32m2013-07-17T23:27:34.455499+00:00 heroku[router]:←[0m at=info method=GET pat
h=/ host=pathetic.herokuapp.com fwd="69.249.253.220" dyno=web.1 connect=2ms serv
ice=11ms status=500 bytes=135
←[32m2013-07-17T23:27:34.782763+00:00 heroku[router]:←[0m at=info method=GET pat
h=/favicon.ico host=pathetic.herokuapp.com fwd="69.249.253.220" dyno=web.1 conne
ct=2ms service=8ms status=500 bytes=135
←[32m2013-07-17T23:27:34.959360+00:00 heroku[router]:←[0m at=info method=GET pat
h=/favicon.ico host=pathetic.herokuapp.com fwd="69.249.253.220" dyno=web.1 conne
ct=2ms service=6ms status=500 bytes=135
←[36m2013-07-17T23:27:46.177839+00:00 heroku[api]:←[0m Scale to web=0 by emailadd
ress@email.com
←[33m2013-07-17T23:27:46.404001+00:00 heroku[web.1]:←[0m State changed from up t
o down
←[36m2013-07-17T23:44:26.986606+00:00 heroku[api]:←[0m Scale to web=1 by emailadd
ress@email.com
←[33m2013-07-17T23:44:34.147645+00:00 heroku[web.1]:←[0m Starting process with c
ommand `gunicorn pathetic.wsgi`
←[33m2013-07-17T23:44:45.317811+00:00 app[web.1]:←[0m 2013-07-17 23:44:45 [2] [I
NFO] Starting gunicorn 17.5
←[33m2013-07-17T23:44:45.318913+00:00 app[web.1]:←[0m 2013-07-17 23:44:45 [2] [I
NFO] Using worker: sync
←[33m2013-07-17T23:44:45.318772+00:00 app[web.1]:←[0m 2013-07-17 23:44:45 [2] [I
NFO] Listening at: http://0.0.0.0:9194 (2)
←[33m2013-07-17T23:44:45.334904+00:00 app[web.1]:←[0m 2013-07-17 23:44:45 [7] [I
NFO] Booting worker with pid: 7
←[33m2013-07-17T23:44:45.397342+00:00 heroku[web.1]:←[0m State changed from star
ting to up

在我看来,似乎有一个错误,Starting process with command 'gunicorn oldtestapp.wsgi'并且ImportError: No module named oldtestapp.wsgi......似乎 Heroku 仍在试图告诉 gunicorn 运行我创建的测试应用程序。我怎样才能让 gunicorn 忘记旧测试应用程序并正确运行我的新应用程序?

如果需要任何其他信息,请告诉我。如果有帮助,我已将项目提交给 git,而不使用 virtualenv。Django 应用程序本身可以正常工作(我已经在其他地方进行了测试,我只是想将它迁移到 heroku。)

我对这个heroku项目中的所有文件进行了全局搜索,试图删除所有出现的“oldtestapp”,但没有找到。

4

1 回答 1

0

对于任何可能偶然遇到相同问题的人,我确实找到了解决方法:

我将 Procfile 更改为:

web: python manage.py run_gunicorn 

本质上,这里的解决方法是将 gunicorn 作为 Django 服务运行,而不是从 Gunicorn 运行 Django。当然gunicorn必须加到settings.py

不过,我仍然不明白原来的问题,因此我认为这是一种解决方法,而不是解决方案——因此,我将把这个问题留着,以防有人偶然发现它的答案。

于 2013-08-03T22:08:00.910 回答