Sha256: 6deebbadd84a182c1f86947f8724f9daac3b537c3b990448be2316a1e755b2be

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# Load ENV vars via Figaro
require 'figaro'
Figaro.application = Figaro::Application.new(environment: 'production', path: File.expand_path('../../../config/application.yml', __FILE__))
Figaro.load

app_path = "#{ENV['DEPLOY_DIRECTORY']}/current"
working_directory app_path

pid "#{app_path}/tmp/pids/unicorn.pid"

stderr_path "#{app_path}/log/unicorn.err.log"
stdout_path "#{app_path}/log/unicorn.out.log"

worker_processes 3
timeout 30
preload_app true

listen "#{app_path}/tmp/sockets/unicorn.sock", backlog: 64

before_exec do |_|
  ENV["BUNDLE_GEMFILE"] = File.join(app_path, "Gemfile")
end

before_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!

  old_pid = "#{app_path}/tmp/pids/unicorn.pid.oldbin"

  if File.exist?(old_pid) && server.pid != old_pid
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
    end
  end
end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
inline_forms-6.2.14 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.12 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.11 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.10 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.9 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.7 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.6 lib/generators/templates/unicorn/production.rb
inline_forms-6.2.5 lib/generators/templates/unicorn/production.rb