Sha256: 6a1dc1807a98292eb3a228879e0c7ecabbb87444967ef8d1e486ce4042f941f1

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 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 <%= unicorn_timeout %>

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

8 entries across 8 versions & 1 rubygems

Version Path
caploy-0.2.5 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.2.4 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.2.3 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.2.2 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.2.1 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.2.0 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.12 lib/caploy/templates/unicorn/unicorn.rb.erb
caploy-0.1.11 lib/caploy/templates/unicorn/unicorn.rb.erb