Sha256: fd9c62b74765bf779af508a6978bb0334104df6e8f2b30cb0ad1c38a5902e3ab
Contents?: true
Size: 1.94 KB
Versions: 8
Compression:
Stored size: 1.94 KB
Contents
require File.expand_path('../config/application', __FILE__) Demo::Application.load_tasks namespace :demo do task limit: :environment do puts '=> Creating sidekiq tasks' 100.times do SlowWorker.perform_async FastWorker.perform_async end run_sidekiq_monitoring run_sidekiq_workers config: <<-YAML :verbose: false :concurrency: 4 :queues: - slow - fast :limits: slow: 1 YAML end task blocking: :environment do puts '=> Creating sidekiq tasks' AWorker.perform_async BWorker.perform_async CWorker.perform_async run_sidekiq_monitoring run_sidekiq_workers config: <<-YAML :verbose: false :concurrency: 4 :queues: - a - b - c :blocking: - a YAML end task advanced_blocking: :environment do puts '=> Creating sidekiq tasks' AWorker.perform_async BWorker.perform_async CWorker.perform_async run_sidekiq_monitoring run_sidekiq_workers config: <<-YAML :verbose: false :concurrency: 4 :queues: - a - b - c :blocking: - [a, b] YAML end def with_sidekiq_config(config) whitespace_offset = config[/\A */].size config.gsub! /^ {#{whitespace_offset}}/, '' puts "=> Use sidekiq config:\n#{config}" File.write 'config/sidekiq.yml', config yield ensure FileUtils.rm 'config/sidekiq.yml' end def run_sidekiq_monitoring require 'sidekiq/web' Thread.new do Rack::Server.start app: Sidekiq::Web, Port: 3000 end sleep 1 Launchy.open 'http://127.0.0.1:3000/busy?poll=true' end def run_sidekiq_workers(options) require 'sidekiq/cli' cli = Sidekiq::CLI.instance %w(validate! boot_system).each do |stub| cli.define_singleton_method(stub) {} end with_sidekiq_config options[:config] do cli.send :setup_options, [] end cli.run end end
Version data entries
8 entries across 8 versions & 2 rubygems