Sha256: e9f16cb5d40dacd9ca3b2baca9ded0b44d724ef8f64c4bff0cc90e933c0ebed2

Contents?: true

Size: 1.34 KB

Versions: 44

Compression:

Stored size: 1.34 KB

Contents

root = "<%= current_path %>"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn_err.log"
stdout_path "#{root}/log/unicorn.log"

listen "/tmp/unicorn.<%= fetch(:full_app_name) %>.sock"
worker_processes <%= fetch(:unicorn_worker_count) %>
timeout 40
preload_app true

# Force unicorn to look at the Gemfile in the current_path
# otherwise once we've first started a master process, it
# will always point to the first one it started.
before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "<%= current_path %>/Gemfile"
end

before_fork do |server, worker|
   defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
  # Quit the old unicorn process
  old_pid = "#{server.config[:pid]}.oldbin"
  if File.exists?(old_pid) && server.pid != old_pid
    puts "We've got an old pid and server pid is not the old pid"
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
      puts "killing master process (good thing tm)"
    rescue Errno::ENOENT, Errno::ESRCH
      puts "unicorn master already killed"
      # someone else did our job for us
    end
  end
end

after_fork do |server, worker|
  port = 5000 + worker.nr
  child_pid = server.config[:pid].sub('.pid', ".#{port}.pid")
  system("echo #{Process.pid} > #{child_pid}")
   defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
teleporter-2.0.11 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.10 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.9 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.8 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.7 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.6 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.4 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.2 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.1 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-2.0.0 lib/generators/teleport/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.2.4 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.2.3 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.2.2 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.2.1 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.1.1 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.1.0 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.0.2 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.0.1 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-1.0.0 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb
teleporter-0.1.0 lib/generators/initial/templates/capistrano/shared/unicorn.rb.erb