2013-11-01 18:57:50 -04:00
|
|
|
require "demon/base"
|
2013-10-09 22:33:52 -04:00
|
|
|
|
|
|
|
class Demon::Sidekiq < Demon::Base
|
2013-11-01 18:57:50 -04:00
|
|
|
|
2013-10-09 22:33:52 -04:00
|
|
|
def self.prefix
|
|
|
|
"sidekiq"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-04-17 01:57:17 -04:00
|
|
|
def suppress_stdout
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def suppress_stderr
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2013-10-09 22:33:52 -04:00
|
|
|
def after_fork
|
2014-04-17 01:57:17 -04:00
|
|
|
STDERR.puts "Loading Sidekiq in process id #{Process.pid}"
|
2013-10-09 22:33:52 -04:00
|
|
|
require 'sidekiq/cli'
|
2014-06-03 03:17:10 -04:00
|
|
|
# CLI will close the logger, if we have one set we can be in big
|
|
|
|
# trouble, if STDOUT is closed in our process all sort of weird
|
|
|
|
# will ensue, resetting the logger ensures it will reinit correctly
|
|
|
|
# parent process is in charge of the file anyway.
|
|
|
|
Sidekiq::Logging.logger = nil
|
2013-11-01 18:57:50 -04:00
|
|
|
cli = Sidekiq::CLI.instance
|
2016-04-06 22:56:43 -04:00
|
|
|
cli.parse(["-c", GlobalSetting.sidekiq_workers.to_s, "-q", "critical,4", "-q", "default,2", "-q", "low"])
|
2014-04-17 01:57:17 -04:00
|
|
|
|
2015-12-08 19:48:41 -05:00
|
|
|
load Rails.root + "config/initializers/100-sidekiq.rb"
|
2013-11-01 18:57:50 -04:00
|
|
|
cli.run
|
|
|
|
rescue => e
|
|
|
|
STDERR.puts e.message
|
|
|
|
STDERR.puts e.backtrace.join("\n")
|
|
|
|
exit 1
|
2013-10-09 22:33:52 -04:00
|
|
|
end
|
2013-11-01 18:57:50 -04:00
|
|
|
|
2013-10-09 22:33:52 -04:00
|
|
|
end
|