Created
November 25, 2013 07:55
-
-
Save arkiver/7637870 to your computer and use it in GitHub Desktop.
Unicorn, Redis, Rescue config for 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
# /initializers/redis.rb | |
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/" ) | |
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) | |
# /initializers/resque.rb | |
Resque.redis = REDIS | |
# unicorn.rb | |
before_fork do |server, worker| | |
if defined?(Resque) | |
Resque.redis.quit | |
Rails.logger.info('Disconnected from Redis') | |
end | |
end | |
after_fork do |server, worker| | |
if defined?(Resque) | |
Resque.redis = REDIS | |
Rails.logger.info('Connected to Redis') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment