From 4aaedb82d09d53159a99c3c94c0232c3cf5b0725 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 23 Apr 2014 11:03:36 +1000 Subject: [PATCH] FEATURE: alllow unicorn master to fork sidekiqs, keep alive coming --- config/unicorn.conf.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb index daf90a46e3e..6b28c2dc1d9 100644 --- a/config/unicorn.conf.rb +++ b/config/unicorn.conf.rb @@ -69,6 +69,23 @@ before_fork do |server, worker| end end + sidekiqs = ENV['UNICORN_SIDEKIQS'].to_i + if sidekiqs > 0 + puts "Starting up #{sidekiqs} supervised sidekiqs" + require 'demon/sidekiq' + + Demon::Sidekiq.start(sidekiqs) + + class ::Unicorn::HttpServer + alias :master_sleep_orig :master_sleep + + def master_sleep(sec) + Demon::Sidekiq.ensure_running + master_sleep_orig(sec) + end + end + end + end ActiveRecord::Base.connection.disconnect!