現在、Capistrano のデプロイ後にデータベース接続に問題があります。データベースサーバーでは、ユニコーンは以前の接続を切断せず、古い接続の上に追加し続けているようです。私は真のプリロードを行っています。それが重要な場合は、タコの宝石もインストールしています。誰がこの責任を負っているのか、私にはよくわかりません。重要な部分にユニコーンの設定を貼り付けました。どんな助けでも大歓迎です!
before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
old_pid = "/tmp/unicorn.my_app_name.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
end
end
end
after_fork do |server, worker|
ActiveRecord::Base.connection_proxy.instance_variable_get(:@shards).each {|k,v| v.clear_reloadable_connections! }
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
end
if Process.ppid > 1 # Not the daemon
child_pid = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")
File.open(child_pid, "wb") {|f| f << Process.pid }
end
end
「psオー」