ryandotsmith / nginx-buildpack

Run NGINX in front of your app server on Heroku
456 stars 0 forks source link

Bad Gateway on Heroku Restart #54

Closed adailey14 closed 9 years ago

adailey14 commented 9 years ago

I'm running this (awesome) buildpack with Puma, and Heroku deployments seem to work perfectly with nginx waiting for puma to start before accepting requests. However I notice that when I do a "heroku restart", I end up getting Bad Gateway 502 errors for the time between nginx re-starting and puma re-starting (at least that's what I think is happening).

Could this be because the /tmp/app-initialized file has already been created from the first deploy, and is not deleted? Should I be deleting the file on restart to prevent this? Sorry if this is an obvious issue - I don't fully understand how heroku's "ephemeral file system" works.

adailey14 commented 9 years ago

Aha I figured out what was going on here. I was touching /tmp/app-initialized in my puma.rb config file - which was happening before puma / rails was actually ready to accept requests. Instead, I moved the file touch to an "after_initialized" block in my production.rb config file like this:

MyApp::Application.configure do config.after_initialize do FileUtils.touch('/tmp/app-initialized') end end

And now everything is working fine. So I'll be closing this issue.