Skip to content

Instantly share code, notes, and snippets.

@andyatkinson
Created December 21, 2013 23:18
Show Gist options
  • Save andyatkinson/8076487 to your computer and use it in GitHub Desktop.
Save andyatkinson/8076487 to your computer and use it in GitHub Desktop.
# example config from a nginx + unicorn + capistrano deploy to a VPS
# "app" is deployed to /var/www/app
# replace "app" with the app name
# The rule of thumb is to use 1 worker per processor core available,.
# however since we'll be hosting many apps on this server,.
# we need to take a less aggressive approach
worker_processes 2
# We deploy with capistrano, so "current" links to root dir of current release
working_directory "/var/www/app/current"
# Listen on unix socket
listen "/tmp/unicorn.app.sock", :backlog => 64
#listen 8080, :tcp_nopush => true
timeout 30
pid "/var/www/app/current/tmp/pids/unicorn.pid"
stderr_path "/var/www/app/current/log/unicorn.log"
stdout_path "/var/www/app/current/log/unicorn.log"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
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