Sha256: f3b8c3fe997b7900c513a9041731eb8dfe1916c17d4413594bbada75a6a6f71a
Contents?: true
Size: 1.94 KB
Versions: 19
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/workers?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
19 entries across 19 versions & 1 rubygems