Skip to content

Instantly share code, notes, and snippets.

@StasKoval
Created June 10, 2014 13:53
Show Gist options
  • Save StasKoval/fee7e80e2a1ad23ae8e8 to your computer and use it in GitHub Desktop.
Save StasKoval/fee7e80e2a1ad23ae8e8 to your computer and use it in GitHub Desktop.
root = "/home/deployer/apps/new-costa/current"
#root = "/home/stas/DEV/Projects/SHapovalov/new-costa"
#root = "/house"
worker_processes 4
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.new-costa.sock", :backlog => 64
listen 8000, :tcp_nopush => true
timeout 30
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|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis. TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment