Last active
August 29, 2015 14:01
-
-
Save braidn/f608cf76b1d7542af8c1 to your computer and use it in GitHub Desktop.
Redis Setup
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
$redis = Redis.new(:url => ENV['REDIS_URL']) |
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
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 7) | |
working_directory "#{ENV['STACK_PATH']}" | |
listen "/tmp/web_server.sock", :backlog => 64 | |
timeout 30 | |
pid '/tmp/web_server.pid' | |
stderr_path "#{ENV['STACK_PATH']}/log/unicorn.stderr.log" | |
stdout_path "#{ENV['STACK_PATH']}/log/unicorn.stdout.log" | |
preload_app true | |
GC.respond_to?(:copy_on_write_friendly=) and | |
GC.copy_on_write_friendly = true | |
check_client_connection false | |
before_fork do |server, worker| | |
old_pid = '/tmp/web_server.pid.oldbin' | |
if File.exists?(old_pid) && server.pid != old_pid | |
begin | |
Process.kill("QUIT", File.read(old_pid).to_i) | |
rescue Errno::ENOENT, Errno::ESRCH | |
# someone else did our job for us | |
end | |
end | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.connection.disconnect! | |
end | |
after_fork do |server, worker| | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.establish_connection | |
$redis.client.reconnect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment