Sha256: a2c5dd08b0d7622f75388ed91af122f0ae46e598f5db7d48b5bc6052121aa046

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

working_directory "<%= current_path %>"
pid "<%= fetch(:unicorn_pid) %>"
stderr_path "<%= fetch(:unicorn_log) %>"
stdout_path "<%= fetch(:unicorn_log) %>"

listen "/tmp/unicorn.<%= fetch(:nginx_config_name) %>.sock"
worker_processes <%= fetch(:unicorn_workers) %>
timeout 30

preload_app true

before_exec do |server|
  ENV["BUNDLE_GEMFILE"] = "<%= current_path %>/Gemfile"
end

before_fork do |server, worker|
  # Disconnect since the database connection will not carry over
  if defined? ActiveRecord::Base
    ActiveRecord::Base.connection.disconnect!
  end

  # Quit the old unicorn process
  old_pid = "#{server.config[: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
    end
  end

  if defined?(Resque)
    Resque.redis.quit
  end

  sleep 1
end

after_fork do |server, worker|
  # Start up the database connection again in the worker
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.establish_connection
  end

  if defined?(Resque)
    Resque.redis = 'localhost:6379'
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
capistrano-nginx-unicorn-0.1.0 lib/generators/capistrano/nginx_unicorn/templates/unicorn.rb.erb
capistrano-unicorn-nginx-1.0.0 lib/generators/capistrano/unicorn_nginx/templates/unicorn.rb.erb
capistrano-unicorn-nginx-0.0.4 lib/generators/capistrano/unicorn_nginx/templates/unicorn.rb.erb
capistrano-unicorn-nginx-0.0.2 lib/generators/capistrano/unicorn_nginx/templates/unicorn.rb.erb
capistrano-unicorn-nginx-0.0.1 lib/generators/capistrano/unicorn_nginx/templates/unicorn.rb.erb
capistrano-nginx-unicorn-0.1.0.pre lib/generators/capistrano/nginx_unicorn/templates/unicorn.rb.erb