【发布时间】:2013-03-13 03:15:37
【问题描述】:
我收到了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
这是我目前设置的:
config/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
config/initializers/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
【问题讨论】:
标签: ruby-on-rails heroku ruby-on-rails-3.2 unicorn sidekiq