2013-04-12 89 views
0

部署我的代碼並訪問該網站後,我得到了H20錯誤。這裏的日誌:服務器錯誤 - heroku,django

2013-04-12T11:45:59.304354+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=olp-website.herokuapp.com fwd="86.151.6.106" dyno= connect= service= status=503 bytes= 

於是,我就簽出DYNOS:

heroku ps --app olp-website 

    === web: newrelic-admin run-program gunicorn -c gunicorn.py.ini wsgi:application 
    web.1: up 2013/04/12 12:46:21 (~ 1m ago) 

heroku ps:restart --app olp-website 

    Restarting processes... done 

heroku ps --app olp-website 

    === web: newrelic-admin run-program gunicorn -c gunicorn.py.ini wsgi:application 
    web.1: starting 2013/04/12 12:48:42 (~ 6s ago) 

現在收到500內部服務器錯誤:

2013-04-12T13:38:19.116492+00:00 app[web.1]: 2013-04-12 13:38:19 [2] [INFO] Listening at: http://0.0.0.0:28853 (2) 
2013-04-12T13:38:19.115928+00:00 app[web.1]: 2013-04-12 13:38:19 [2] [INFO] Starting gunicorn 0.14.3 
2013-04-12T13:38:19.116593+00:00 app[web.1]: 2013-04-12 13:38:19 [2] [INFO] Using worker: gevent 
2013-04-12T13:38:19.122714+00:00 app[web.1]: 2013-04-12 13:38:19 [5] [INFO] Booting worker with pid: 5 
2013-04-12T13:38:19.135537+00:00 app[web.1]: 2013-04-12 13:38:19 [7] [INFO] Booting worker with pid: 7 
2013-04-12T13:38:19.129099+00:00 app[web.1]: 2013-04-12 13:38:19 [6] [INFO] Booting worker with pid: 6 
2013-04-12T13:38:19.140715+00:00 app[web.1]: 2013-04-12 13:38:19 [8] [INFO] Booting worker with pid: 8 
2013-04-12T13:38:19.393488+00:00 heroku[web.1]: State changed from starting to up 
2013-04-12T13:38:20.310391+00:00 app[web.1]: 2013-04-12 13:38:20,310 (5/Dummy-2) newrelic.core.agent INFO - New Relic Python Agent (1.3.0.289) 
2013-04-12T13:38:21.072892+00:00 heroku[router]: at=info method=GET path=/ host=olp-website.herokuapp.com fwd="86.151.6.106" dyno=web.1 connect=31ms service=761ms status=500 bytes=5 

我看不出有什麼不對因爲代碼在開發中工作正常,並且我正在使用django-skel設置文件進行生產。

你有什麼想法可以設置錯誤嗎?

編輯:只要看看關於heroku的數據庫信息,它看起來像數據庫有0個表 - 所以我猜sqlite databse沒有遷移到postresql。

回答

0

H20錯誤通常表示您的應用需要很長時間才能在閒置後啓動。

The router will enqueue requests for 75 seconds while waiting for starting processes to reach an 「up」 state. If after 75 seconds, no web dynos have reached an 「up」 state, the router logs H20 and serves a standard error page.

您必須檢查是否該資產預編譯或是否有可能放緩的app啓動其他的事情。

調試超時:

一個請求的超時的原因是在代碼中無限循環。在本地進行測試,看看是否可以複製問題並修復該錯誤。

另一種可能是你正在嘗試做一些長時間運行的任務你的web程序中,如:

Sending an email 
Accessing a remote API 
Web scraping/crawling 
Rendering an image or PDF 
Heavy computation 
Heavy database usage (slow or numerous queries) 

如果是的話,你應該將這個繁重進入後臺作業,其能從您的Web請求異步運行。

當您的應用程序使用的外部服務不可用或超載時,會發生另一類超時。在這種情況下,除非將工作移動到後臺,否則您的Web應用很可能會超時。在某些情況下,您必須在您的網絡請求期間處理這些請求,您應該始終計劃失敗情況。

+0

靜態資產已被壓縮並上傳到Amazon S3。這只是一個非常小的應用程序,在我的開發服務器上運行良好,所以我不認爲那裏有問題。它可以做與數據庫(見我上面的編輯)?此外,在重新啓動dynos之後,錯誤更改爲500內部服務器錯誤。 – babbaggeii

+0

超時有很多原因。正如你所說的關於數據庫,你有代碼中的無限循環嗎? – catherine

+0

發送電子郵件,訪問遠程API(發佈到Twitter,查詢Flickr等),網頁抓取/抓取,呈現圖像或PDF,重計算,重數據庫使用(緩慢或衆多查詢) – catherine