Heroku 無法啟動我的應用程序,但 `foreman start` 工作 (Heroku fails to start my app, but `foreman start` works)


問題描述

Heroku 無法啟動我的應用程序,但 foreman start 工作 (Heroku fails to start my app, but foreman start works)

I'm attempting to deploy a fairly simple Flask app to Heroku's cedar stack, but I keep seeing the following error:

2012‑08‑09T22:37:49+00:00 heroku[web.1]: State changed from crashed to starting
2012‑08‑09T22:37:52+00:00 heroku[web.1]: Starting process with command `gunicorn pytips.app:create_app() ‑b 0.0.0.0:42152 ‑w 3`
2012‑08‑09T22:37:53+00:00 app[web.1]: bash: ‑c: line 0: syntax error near unexpected token `('
2012‑08‑09T22:37:53+00:00 app[web.1]: bash: ‑c: line 0: `gunicorn pytips.app:create_app() ‑b 0.0.0.0:42152 ‑w 3'

And I have this as my Procfile:

web: gunicorn pytips.app:create_app() ‑b 0.0.0.0:$PORT ‑w 3

When I test this locally by running foreman start, things work just fine. Why is Heroku having problems if foreman is fine with it locally?

UPDATE: I've also tried testing with heroku run. Here's what that yields:

heroku run ‑‑app pytips gunicorn pytips.app:create_app() ‑b 0.0.0.0:$PORT ‑w 3

gives me nothing.

heroku run ‑‑app pytips 'gunicorn pytips.app:create_app() ‑b 0.0.0.0:$PORT ‑w 3'

gives me heroku:108: command not found: ‑b.

‑‑‑‑‑

參考解法

方法 1:

My current solution is this: I escape the parentheses, e.g.,

web: gunicorn pytips.app:create_app\(\) ‑b 0.0.0.0:$PORT ‑w 3

While this totally explodes on my local box, it seems to work just peachy on Heroku's system. I am still hoping the support team at Heroku can figure out why it works in one place, but not the other. Until then, I will just test locally with the the unescaped version, then put the escapes back before pushing to Heroku.

方法 2:

I was getting the same error 500s with nothing in the logs. 

Turned out that Heroku did not like my local SQLite database. I was able to set up the free PostgreSQL database and the error went away. 

I followed this tutorial. 

http://blog.y3xz.com/blog/2012/08/16/flask‑and‑postgresql‑on‑heroku/

方法 3:

so the first thing is your gunicorn command is incorrect. When you run gunicorn, you need to pass it your app instance. So for example, if your Flask app is defined inside a pytips.py file, you would run gunicorn by doing: gunicorn pytips:app ‑b ....

If you change that, I'm guessing it will work fine, as the rest of your stuff looks good.

(by Hank GayHank GayNick Woodhamsrdegges)

參考文件

  1. Heroku fails to start my app, but foreman start works (CC BY‑SA 3.0/4.0)

#gunicorn #Flask #Heroku






相關問題

Heroku 無法啟動我的應用程序,但 `foreman start` 工作 (Heroku fails to start my app, but `foreman start` works)

為什麼不再推薦 gunicorn_django ? (Why is gunicorn_django not recommended anymore?)

Supervisord 拋出錯誤:“無法執行 /var/application/gunicorn_start:ENOEXEC” (Supervisord throws error: "couldn't exec /var/application/gunicorn_start: ENOEXEC")

服務器上更改的 HTML 文件未反映 (The HTML file changed on server is not reflected)

在 gae flexible 上長時間運行的雲任務會提前終止而不會出錯。如何調試?我錯過了什麼? (Long running cloud task on gae flexible terminates early without error. How to debug? What am I missing?)

Gunicorn 沒有自動啟動 (Gunicorn not starting automatically)

nginx的配置文件中的主機名未知? (Hostname in configfile of nginx unkown?)

重新啟動 gunicorn 和 nginx 不會反映拉取請求後的更改 (restarting gunicorn and nginx doesn't reflect changes after pull request)

當 gunicorn / celery 服務重新啟動時,Django 中有沒有辦法只執行一次 python 代碼? (Is there a way in Django to execute some python code only once when gunicorn / celery services are getting restarted?)

ModuleNotFoundError:在 Heroku 服務器上使用 Django 和 Gunicorn 時沒有名為“App Name”的模塊 (ModuleNotFoundError: No module named 'App Name' when using Django and Gunicorn on a heroku server)

kubernetes 正在暴露未聲明的端口 (kubernetes is exposing not declared port)

PM2.js 在 Virtualenv/Anaconda 環境中運行 Gunicorn/Flask 應用程序 (PM2.js to Run Gunicorn/Flask App inside Virtualenv/Anaconda env)







留言討論