Skip to content

Commit

Permalink
config unicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
kayakjang committed Jan 18, 2012
1 parent c71b49f commit 9779904
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
6 changes: 3 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Application < Rails::Application

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

config.middleware.insert 1, 'Dragonfly::Middleware', :images

end
end
end
39 changes: 37 additions & 2 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
worker_processes 1 # amount of unicorn workers to spin up
timeout 300
module Rails
class << self
def root
File.expand_path(__FILE__).split('/')[0..-3].join('/')
end
end
end

# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'

preload_app true
working_directory Rails.root

pid "#{Rails.root}/tmp/pids/unicorn.pid"
stderr_path "#{Rails.root}/log/unicorn.log"
stdout_path "#{Rails.root}/log/unicorn.log"

# 4 workers and 1 master
worker_processes (rails_env == 'production' ? 4 : 2)
timeout 120

listen '/tmp/sockets/unicorn.durex.sock'
listen 4000, :tcp_nopush => false

before_fork do |server, worker|
old_pid = "#{Rails.root}/tmp/pids/unicorn.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
puts "Send 'QUIT' signal to unicorn error!"
end
end
end


0 comments on commit 9779904

Please sign in to comment.