lib/good_job/cli.rb in good_job-1.1.0 vs lib/good_job/cli.rb in good_job-1.1.1

- old
+ new

@@ -8,46 +8,19 @@ method_option :max_threads, type: :numeric, desc: "Maximum number of threads to use for working jobs (default: ActiveRecord::Base.connection_pool.size)" method_option :queues, type: :string, - banner: "queue1,queue2", - desc: "Queues to work from. Separate multiple queues with commas (default: *)" + banner: "queue1,queue2(;queue3,queue4:5)", + desc: "Queues to work from. Separate multiple queues with commas; separate isolated execution pools with semicolons and threads with colons (default: *)" method_option :poll_interval, type: :numeric, desc: "Interval between polls for available jobs in seconds (default: 1)" def start set_up_application! - max_threads = ( - options[:max_threads] || - ENV['GOOD_JOB_MAX_THREADS'] || - ENV['RAILS_MAX_THREADS'] || - ActiveRecord::Base.connection_pool.size - ).to_i - - queue_string = ( - options[:queues] || - ENV['GOOD_JOB_QUEUES'] || - '*' - ) - - poll_interval = ( - options[:poll_interval] || - ENV['GOOD_JOB_POLL_INTERVAL'] - ).to_i - - job_query = GoodJob::Job.queue_string(queue_string) - job_performer = GoodJob::Performer.new(job_query, :perform_with_advisory_lock, name: queue_string) - - timer_options = {} - timer_options[:execution_interval] = poll_interval if poll_interval.positive? - - pool_options = { - max_threads: max_threads, - } - - scheduler = GoodJob::Scheduler.new(job_performer, timer_options: timer_options, pool_options: pool_options) + configuration = Configuration.new(options, env: ENV) + scheduler = Scheduler.from_configuration(configuration) @stop_good_job_executable = false %w[INT TERM].each do |signal| trap(signal) { @stop_good_job_executable = true } end