如果你在Heroku上的一个dyno上设置了Unicorn,那就说3个工人.是否有可能让2个子工作者处理Web请求,1个Unicorn子进行后台作业,例如resque队列或计划任务?
或者那是不合适的?
现在搞定了!
好的,所以使用下面的答案,我设法得到它来获取提示,但它首先需要一些修修补补.这对我有用.
Procfile
web: bundle exec unicorn_rails -p $PORT -c config/unicorn.rb
Run Code Online (Sandbox Code Playgroud)
unicorn.rb
worker_processes 2
preload_app true
timeout 30
@resque_pid = nil
before_fork do |server, worker|
@resque_pid ||= spawn("bundle exec rake environment resque:work QUEUE=*")
end
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
Run Code Online (Sandbox Code Playgroud)