-
-
Save elijahmurray/552b69350e81acab5ec2 to your computer and use it in GitHub Desktop.
Gist to get sidekiq up and running on heroku with puma.
This file contains hidden or 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
# Gemfile | |
gem "puma" | |
gem 'sidekiq', '~> 2.2.1' | |
# gem 'autoscaler' | |
# Procfile | |
web: bundle exec puma -p $PORT -e $RACK_ENV | |
# add to config block config/environments/production.rb | |
# This is becoming deprecated and needs to be updated. | |
config.threadsafe! | |
# Add redis to heroku | |
heroku addons:add redistogo | |
#https://addons.heroku.com/redistogo#nano | |
# Actual worker. | |
# Don't use i_vars (@id). Needs to be threadsafe and should look up for speed, safety. | |
class MyWorker | |
include Sidekiq::Worker | |
def perform(id) | |
puts object = Model.find(id) | |
end | |
end | |
# Call long job in a view, controller or model | |
MixpanelWorker.perform_async(@object) | |
# | |
# Local testing | |
# start redis, server, and sidekiq | |
redis-server /usr/local/etc/redis.conf | |
bundle exec rails server | |
bundle exec sidekiq | |
# get rid of NewRelic after_fork code, if you were doing this: | |
# http://support.newrelic.com/kb/troubleshooting/unicorn-no-data | |
# and get rid of config/unicorn.rb if you were using that | |
# if you use NewRelic, set your NEWRELIC_DISPATCHER environment variable on heroku, per | |
# https://github.com/puma/puma/issues/128 - may not be needed for future releases of Puma | |
heroku config:add NEWRELIC_DISPATCHER=Puma | |
# For autoscaling up dynos on heroku (cost effective), checkout this guide starting with the the | |
# Adding the autoscaler part | |
http://manuel.manuelles.nl/blog/2012/11/13/scalable-heroku-worker-for-sidekiq/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment