Sha256: 7772ce7526931f4466010cfbb1920fffa537f5efe03840bfcdd65f69da3f500a

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

working_directory "<%= current_path %>"
pid "<%= unicorn_pid %>"
stderr_path "<%= unicorn_std_log %>"
stdout_path "<%= unicorn_err_log %>"

listen "/tmp/socket.<%= application %>_<%= stage %>.sock", :backlog => <%= unicorn_listen_backlog %>
worker_processes <%= unicorn_worker_processes %>
timeout 30

preload_app true

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

    # This allows a new master process to incrementally
    # phase out the old master process with SIGTTOU to avoid a
    # thundering herd (especially in the "preload_app false" case)
    # when doing a transparent upgrade.  The last worker spawned
    # will then kill off the old master process with a SIGQUIT.
    old_pid = "#{server.config[:pid]}.oldbin"
    if File.exists?(old_pid) && old_pid != server.pid
      begin
        sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
        Process.kill(sig, File.read(old_pid).to_i)
      rescue Errno::ENOENT, Errno::ESRCH
      end
    end
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?(Sidekiq)
      Sidekiq.configure_client do |config|
        config.redis = { :size => <%= sidekiq_redis_count %> }
      end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
caploy-0.1.7 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.6 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.5 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.4 lib/caploy/templates/unicorn/unicorn.rb.erb