Sha256: 65637db5d9d3a12d7bd85e07c8ddfee4d54b81354f7899663d2015d861001bdd

Contents?: true

Size: 828 Bytes

Versions: 9

Compression:

Stored size: 828 Bytes

Contents

require 'yaml'

rails_root = "#{File.dirname(File.expand_path(__FILE__))}/.."
rails_env = ENV['RAILS_ENV'] || 'development'

worker_processes 2
working_directory rails_root

database = YAML.load_file("#{File.dirname(__FILE__)}/database.yml")[rails_env]['database']
listen "/tmp/#{database}.sock"
timeout 300

stdout_path rails_root + '/log/unicorn.log'
stderr_path rails_root + '/log/unicorn.log'

preload_app true

before_fork do |server, worker|
  ActiveRecord::Base.connection.disconnect!
  old_pid = "#{server.config[:pid]}.oldbin"
  if old_pid != server.pid
    begin
      sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
      Process.kill(sig, File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
    end
  end
end

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
daddy-0.3.29 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.28 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.27 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.26 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.25 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.24 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.23 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.22 lib/tasks/unicorn/unicorn.rb.erb
daddy-0.3.21 lib/tasks/unicorn/unicorn.rb.erb