Skip to content

Instantly share code, notes, and snippets.

@leshill
Created November 28, 2011 20:01
Show Gist options
  • Save leshill/1401792 to your computer and use it in GitHub Desktop.
Save leshill/1401792 to your computer and use it in GitHub Desktop.
Unicorn config for cedar stack on Heroku.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
# config/unicorn.rb
# See comment by @paulelliott
worker_processes 3
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis.quit
Rails.logger.info('Disconnected from Redis')
end
end
after_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info('Connected to ActiveRecord')
end
# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis = ENV['REDIS_URI']
Rails.logger.info('Connected to Redis')
end
end
@josh803316
Copy link

@harlow Did you figure the Redis config out. Im using Redistogo without Resque and can't find much in the way of configs like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment