ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

worker_processes 5
preload_app true
pid File.join(ROOT, 'tmp', 'pids', 'unicorn.pid')
stdout_path '/var/log/aaf/saml/unicorn/stdout.log'
stderr_path '/var/log/aaf/saml/unicorn/stderr.log'

timeout 240

before_fork do |server, _worker|
  Sequel::Model.db.disconnect

  old_pid = File.join(ROOT, '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
      :not_running
    end
  end
end

class Unicorn::HttpServer # rubocop:disable ClassAndModuleChildren
  def proc_name(tag)
    $0 = ([File.basename(START_CTX[0]), 'saml',
           tag]).concat(START_CTX[:argv]).join(' ')
  end
end

ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

worker_processes 5
preload_app true
pid File.join(ROOT, 'tmp', 'pids', 'unicorn.pid')
stdout_path '/var/log/aaf/saml/unicorn/stdout.log'
stderr_path '/var/log/aaf/saml/unicorn/stderr.log'

timeout 600

before_fork do |server, _worker|
  Sequel::Model.db.disconnect

  old_pid = File.join(ROOT, '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
      :not_running
    end
  end
end

class Unicorn::HttpServer # rubocop:disable ClassAndModuleChildren
  def proc_name(tag)
    $0 = ([File.basename(START_CTX[0]), 'saml',
           tag]).concat(START_CTX[:argv]).join(' ')
  end
end

Update request timeout to 10 minutes
Update request timeout to 10 minutes

Under load (generally relating to something upstream like the DB
cluster being pegged by a 3rd party service), valid but long running
queries can be timed out before practical.

This will allow us to continue to respond in these situations without
being hard terminated, albeit slowly.
