Skip to content

Commit

Permalink
[NOSTORY] Add whacamole for restarting heroku dynos on production whe…
Browse files Browse the repository at this point in the history
…n they hit memory limits.
  • Loading branch information
hypernormal committed Jun 6, 2018
1 parent fa719d7 commit 18e4c6c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
Binary file modified .env.development.gpg
Binary file not shown.
Binary file modified .env.heroku/1dc44930d2cea05792388a1178c936fe.gpg
Binary file not shown.
Binary file modified .env.heroku/affinityworks.gpg
Binary file not shown.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ gem 'rbnacl-libsodium'
gem 'factory_bot_rails'
gem 'faker'

# heroku memory monitor / worker restarter
gem 'whacamole'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'dotenv-rails'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ GEM
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whacamole (1.2.0)
wicked_pdf (1.1.0)
wkhtmltopdf-binary-edge (0.12.4.0)
wkhtmltopdf-heroku (2.12.4.0)
Expand Down Expand Up @@ -589,6 +590,7 @@ DEPENDENCIES
valid_attribute
web-console
webmock
whacamole
wicked_pdf
wkhtmltopdf-binary-edge (~> 0.12.4.0)
wkhtmltopdf-heroku
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
release: bundle exec rake heroku:release
web: bundle exec puma -C config/puma.rb
worker: bundle exec rake jobs:work
whacamole: bundle exec whacamole -c ./config/whacamole.rb

# comment: consider bin/rails server -p $PORT -e $RAILS_ENV for web (old heroku default)
13 changes: 13 additions & 0 deletions config/whacamole.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Whacamole.configure("affinityworks") do |config|
config.api_token = ENV['HEROKU_API_TOKEN']
config.dynos = %w{web}
config.restart_threshold = 1000 # MB
config.restart_window = 30*60 # SECONDS
end

Whacamole.configure("production-swingleft") do |config|
config.api_token = ENV['HEROKU_API_TOKEN']
config.dynos = %w{web}
config.restart_threshold = 500 # MB
config.restart_window = 30*60 # SECONDS
end

0 comments on commit 18e4c6c

Please sign in to comment.