Sha256: d1c0fa1ac9d0d3d5e46aa8d2fd9e305439196557bf6eae262901aa977de43807

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

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

    # Quit the old unicorn process
    old_pid = "#{server.config[:pid]}.oldbin"
    if File.exists?(old_pid) && server.pid != old_pid
        begin
            Process.kill("QUIT", File.read(old_pid).to_i)
        rescue Errno::ENOENT, Errno::ESRCH
            # someone else did our job for us
        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

1 entries across 1 versions & 1 rubygems

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