简体   繁体   中英

How to debug Rails app that crashes on Heroku, runs fine locally

My Rails app runs fine locally. However when I pushed it to Heroku, it suddenly gives me Status 503 and I can't even go to the home page, which is a static page.

The odd thing is that the app successfully builds and deploys on Heroku. But when I try to go to my app, it says "Application error." The logs from running heroku logs -tail only tell me this:

at=error code=H10 desc="App crashed" method=GET path="/" 
host=flow-portal-rails.herokuapp.com 
request_id=3a4ff52c-9ff2-44b0-a701-038b74319bf9 
fwd="107.143.141.1" dyno= connect= service= status=503 
bytes= protocol=https

I am using BUNDLER 2.0.1, my Gemfile is correct. I am not sure what is making my app suddenly behave like this.

One thing you can try is setting:

config.eager_load = true

in your config/environments/development.rb .

If you have config.eager_load = false , then you might have problems in your app that you don't see in development because the culprit code isn't getting accessed (and, therefore, loaded).

In Heroku production , in contrast, all your code is getting loaded and might be surfacing problems you don't see in development .

When loading your entire app in development, then you might see the same issues that you're encountering on Heroku.

Now, setting config.eager_load = true might cause you various slow-downs in development, so keep that in mind. I set config.eager_load = true in development all the time because I got tired of the kind of unexpected crashes you're describing.

Or, this might not help at all. You'll have to see.

I think the problem is in migrations that you run all the migrations on server properly but on Heroku all the migrations are not run properly.

Now you have two options:-

  1. Rollback all your migrations and then run one by one each migration and deploy it to the Heroku.

  2. Just delete the existing app on Heroku and make a new app then just deploy all your code from GitHub

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM