Created
March 28, 2011 17:18
-
-
Save lucasdupin/890867 to your computer and use it in GitHub Desktop.
Default unicorn.rb
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
basepath = File.expand_path File.join(File.dirname(__FILE__), '..') | |
worker_processes 2 | |
working_directory basepath | |
# This loads the application in the master process before forking | |
# worker processes | |
# Read more about it here: | |
# http://unicorn.bogomips.org/Unicorn/Configurator.html | |
preload_app true | |
timeout 30 | |
# This is where we specify the socket. | |
# We will point the upstream Nginx module to this socket later on | |
listen "#{basepath}/tmp/sockets/unicorn.sock", :backlog => 64 | |
pid "#{basepath}/tmp/pids/unicorn.pid" | |
# Set the path of the log files inside the log folder of the testapp | |
stderr_path "#{basepath}/log/unicorn.stderr.log" | |
stdout_path "#{basepath}/log/unicorn.stdout.log" | |
before_fork do |server, worker| | |
# This option works in together with preload_app true setting | |
# What is does is prevent the master process from holding | |
# the database connection | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.connection.disconnect! | |
end | |
after_fork do |server, worker| | |
# Here we are establishing the connection after forking worker | |
# processes | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.establish_connection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment