Last active
October 4, 2015 12:28
-
-
Save jamiew/2636487 to your computer and use it in GitHub Desktop.
Using unicorn on Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initailizers/newrelic_reconnect.rb | |
# Ensure the agent is started using Unicorn | |
# This is needed when using Unicorn and preload_app is NOT set to true. | |
# https://newrelic.com/docs/ruby/no-data-with-unicorn | |
NewRelic::Agent.after_fork(:force_reconnect => true) if defined? Unicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/unicorn.rb | |
# Minimal Heroku unicorn config | |
# * I found no real gain from enabling preload_app on Heroku (which makes for faster worker starts/restarts), | |
# and it will cause strange issues if you don't re-establish all connections correctly | |
# * Heroku has a 30s timeout so we set to 60, allowing them to handle timeouts and issue an H12 error | |
# * Depending on your memory usage workers can be bumped to 3-4. With Sinatra it can be 8+ | |
worker_processes 3 | |
timeout 60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've just updated this and increased timeout to >30s timeout, which allows Heroku to handle killing slow workers and issuing an H12. Heroku router errors can be monitored more easily