Sha256: b7d49263e03f9586789eabf705e5d4f95e679a05659c82270f6d5e8bde2379ea

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 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

2 entries across 2 versions & 1 rubygems

Version Path
caploy-0.1.10 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.9 lib/caploy/templates/unicorn/unicorn.rb.erb