コアと同じ数のワーカーがある場合、デフォルトで受信リクエストを同時に処理する必要があることを理解しています。リクエストが同期的にしか処理されないのはなぜですか?
これが私のunicorn.rbです:
worker_processes 10
APP_PATH = "/var/www/myapp/current" # available in 0.94.0+
APP_PATH_SHARED = "/var/www/myapp/shared"
working_directory APP_PATH
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 60
# feel free to point this anywhere accessible on the filesystem
pid APP_PATH_SHARED + "/pids/unicorn.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path APP_PATH_SHARED + "/log/unicorn.stderr.log"
stdout_path APP_PATH_SHARED + "/log/unicorn.stdout.log"
# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "/var/www/myapp/current/Gemfile"
end
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# Before forking, kill the master process that belongs to the .oldbin PID.
# This enables 0 downtime deploys.
old_pid = APP_PATH_SHARED + "/pids/unicorn.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|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
これは何週間も私を悩ませてきました!ありがとうございました。