gpt4 book ai didi

ruby-on-rails - 在 Heroku 上正确配置 Unicorn 和 Sidekiq

转载 作者:行者123 更新时间:2023-12-04 02:53:12 24 4
gpt4 key购买 nike

我收到 ActiveRecord::StatementInvalid (PG::Error: SSL error: decryption failed or bad record mac错误所以我跟着这个 guide about deploying Unicorn to Heroku它似乎已经修复了它。然而在caveats下它显示了如何配置 Resque对于这样的设置 - 我是否必须对 Sidekiq 做类似的事情? ?

Heroku 的示例代码:

before_fork do |server, worker|

...

# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis.quit
Rails.logger.info('Disconnected from Redis')
end
end

after_fork do |server, worker|

...

# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis = ENV['REDIS_URI']
Rails.logger.info('Connected to Redis')
end
end

这是我目前设置的:

配置/unicorn.rb
worker_processes 2
timeout 30
preload_app true

before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end

配置/初始化程序/sidekiq.rb
require 'sidekiq'

Sidekiq.configure_client do |config|
config.redis = { :size => 1 }
end

Sidekiq.configure_server do |config|
config.redis = { :size => 6 }
end

配置文件
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb
worker: bundle exec sidekiq -e production -c 4

最佳答案

sidekiq 2.9.0 版本起,unicorn/passenger 无需配置after_fork .

这是release notes for version 2.9.0与提到的问题。

这是resolved issue解决 fork 连接。

最后,这是一个 comment from the maintainer确认 after_fork 中的配置不再需要。

关于ruby-on-rails - 在 Heroku 上正确配置 Unicorn 和 Sidekiq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15584339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com