My Django app在本地正常工作,有時推送到Heroku成功,但heroku日誌顯示錯誤(並且該應用程序無法在線加載)。似乎我的Procfile有問題(或者我的virtualenv,雖然我已經重新做了所有的事情來解決這個問題)。爲什麼我的Django應用程序在本地工作,但不在Heroku上?
我試過很多這樣的版本我Procfile:
web: python manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT proj/prod_settings.py
這:
web: python manage.py runserver 0.0.0.0:$PORT collectstatic --noinput
--settings=proj/prod_settings.py
這:
web: gunicorn bookfairy.wsgi.py
,但我一直喜歡這些收到錯誤:
-foreman start pid 17199 result: no such option: --noinput
-foreman start pid 17229 result: no such option: --workers
-foreman start pid 17299 result: Could not import settings 'proj/prod_settings.py' (Is it on sys.path?): Import by filename is not supported.
-Push failed: slug archive could not be created
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to heroku
-foreman start pid 16943 result: Error: Usage is runserver [optional port number, or ipaddr:port]
-Process exited with status 1
State changed from starting to crashed
-heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/robots.txt host=bookfairy.herokuapp.com fwd="66.249.72.200" dyno= connect= service= status=503 bytes=
-heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/robots.txt host=bookfairy.herokuapp.com fwd="173.199.115.131" dyno= connect= service= status=503 bytes=
這:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/__init__.py", line 317, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/app/.heroku/python/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
我能想到的,這個事情我已經試過:
- 拆卸和更換我的Procfile(資本,是)
- 做PIP凍結我的requirements.txt文件
- 增加了一個runtime.txt文件
- 啓動了一個動態代碼
- 隨後所有的Heroku的Django的指令
- 重新排列的我的目錄結構(和移動我wsgi.py文件相同的文件夾 requirements.txt)
- 試圖run_gunicorn(未知命令錯誤)
- PIP 安裝了所有的依賴項(兩次,包括Django,psycopg2, dj-database-url)
- heroku run python manage.py syncdb(服務器是否運行在主機「localhost」(127.0.0.1)並接受TCP/IP連接端口5432?)
- 已檢查Postgres和Heroku toolbelt inst allations
我將非常感謝您的幫助。
我剛收到來自Heroku的電子郵件。顯然,「推送失敗:slug歸檔文件無法創建」錯誤是由迴歸引起的,現在問題已修復。 –