Is it possible to have one Unicorn child process a queue, whilst the rest process web requests on Heroku single Dyno?

StackOverflow https://stackoverflow.com/questions/8907281

If you have Unicorn set up on a single dyno on Heroku, say with 3 workers. Is it possible to have 2 of the child workers processing web requests, and 1 Unicorn child doing background jobs, such as a resque queue, or scheduled tasks?

Or is that just not appropriate?


Now got it Working!

OK, so using the answer bellow I managed to get it to pick up the cue, but it took a bit of tinkering first. This is what worked for me.

Procfile

web: bundle exec unicorn_rails -p $PORT -c config/unicorn.rb

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

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top