Sha256: 5c211f7a729c04cbe20257d291277a5cc2f63de181d9470cce9436905eb9da01

Contents?: true

Size: 1.78 KB

Versions: 28

Compression:

Stored size: 1.78 KB

Contents

##############################################
# Platan.us Sample Unicorn Configuration File
##############################################

# Load rails into the master before forking workers
# for super-fast worker spawn times
preload_app <%= fetch(:unicorn_preload) %>

working_directory "<%= fetch(:current_path) %>"
pid "<%= fetch(:unicorn_pid) %>"
stderr_path "<%= fetch(:current_path) %>/log/unicorn-error.log"
stdout_path "<%= fetch(:current_path) %>/log/unicorn-out.log"

listen "<%= fetch(:app_server_socket) %>"

worker_processes <%= fetch(:unicorn_workers) %>
timeout <%= fetch(:unicorn_workers_timeout) %>

before_fork do |server, worker|
  ##
  # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
  # immediately start loading up a new version of itself (loaded with a new
  # version of our app). When this new Unicorn is completely loaded
  # it will begin spawning workers. The first worker spawned will check to
  # see if an .oldbin pidfile exists. If so, this means we've just booted up
  # a new Unicorn and need to tell the old one that it can now die. To do so
  # we send it a QUIT.
  #
  # Using this method we get 0 downtime deploys.

  defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect!

  old_pid = "<%= fetch(: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
      # someone else did our job for us
      puts "Old master already dead"
    end
  end
end

after_fork do |server, worker|
  ##
  # Unicorn master loads the app then forks off workers - because of the way
  # Unix forking works, we need to make sure we aren't using any of the parent's
  # sockets, e.g. db connection

  ActiveRecord::Base.establish_connection
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
negroku-1.1.14 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.13 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.12 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.11 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.10 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.9 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.8 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.7 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.6 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.5 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.4 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.3 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.2 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.1 lib/negroku/tasks/templates/unicorn.erb
negroku-1.1.0 lib/negroku/tasks/templates/unicorn.erb
negroku-1.0.0 lib/negroku/tasks/templates/unicorn.erb
negroku-0.0.12 lib/negroku/tasks/templates/unicorn.erb
negroku-0.0.11 lib/negroku/tasks/templates/unicorn.erb
negroku-0.0.10 lib/negroku/tasks/templates/unicorn.erb
negroku-0.0.9 lib/negroku/tasks/templates/unicorn.erb