Sha256: 7c785dbe48f325a1059f6bde555175054012ca54f05d6722104afafa580fb0c3

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 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|
        <% if sidekiq_redis_url %>
        config.redis = { :url => <%= sidekiq_redis_url %>, :size => <%= sidekiq_redis_count %> }
        <% else %>
        config.redis = { :size => <%= sidekiq_redis_count %> }
        <% end %>
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caploy-0.1.8 lib/caploy/templates/unicorn/unicorn.rb.erb