Sha256: 8bcb3dc0201961521b0d0559003ca518ba700423e07d88f498ae503c1003da29
Contents?: true
Size: 1.72 KB
Versions: 5
Compression:
Stored size: 1.72 KB
Contents
require 'sidekiq' require 'roo_on_rails/config' require 'roo_on_rails/statsd' require 'roo_on_rails/sidekiq/settings' require 'roo_on_rails/sidekiq/sla_metric' module RooOnRails module Railties class Sidekiq < Rails::Railtie initializer 'roo_on_rails.sidekiq' do |app| require 'hirefire-resource' if RooOnRails::Config.sidekiq_enabled? $stderr.puts 'initializer roo_on_rails.sidekiq' config_sidekiq config_sidekiq_metrics config_hirefire(app) else $stderr.puts 'skipping initializer roo_on_rails.sidekiq' end end def config_hirefire(app) unless ENV['HIREFIRE_TOKEN'] warn 'No HIREFIRE_TOKEN token set, auto scaling not enabled' return end add_middleware(app) end def config_sidekiq ::Sidekiq.configure_server do |x| x.options[:concurrency] = RooOnRails::Sidekiq::Settings.concurrency.to_i x.options[:queues] = RooOnRails::Sidekiq::Settings.queues end end def config_sidekiq_metrics require 'sidekiq/middleware/server/statsd' ::Sidekiq.configure_server do |x| x.server_middleware do |chain| chain.add ::Sidekiq::Middleware::Server::Statsd, client: RooOnRails.statsd end end rescue LoadError $stderr.puts 'Sidekiq metrics unavailable without Sidekiq Pro' end def add_middleware(app) $stderr.puts 'HIREFIRE_TOKEN set' app.middleware.use HireFire::Middleware HireFire::Resource.configure do |config| config.dyno(:worker) do RooOnRails::Sidekiq::SlaMetric.queue end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems