lib/good_job/cli.rb in good_job-1.1.3 vs lib/good_job/cli.rb in good_job-1.1.4

- old
+ new

@@ -16,33 +16,37 @@ type: :numeric, desc: "Interval between polls for available jobs in seconds (default: 1)" def start set_up_application! - configuration = Configuration.new(options, env: ENV) - scheduler = Scheduler.from_configuration(configuration) + notifier = GoodJob::Notifier.new + configuration = GoodJob::Configuration.new(options) + scheduler = GoodJob::Scheduler.from_configuration(configuration) + notifier.recipients << [scheduler, :create_thread] @stop_good_job_executable = false %w[INT TERM].each do |signal| trap(signal) { @stop_good_job_executable = true } end Kernel.loop do sleep 0.1 - break if @stop_good_job_executable || scheduler.shutdown? + break if @stop_good_job_executable || scheduler.shutdown? || notifier.shutdown? end + notifier.shutdown scheduler.shutdown end default_task :start desc :cleanup_preserved_jobs, "Delete preserved job records" method_option :before_seconds_ago, type: :numeric, default: 24 * 60 * 60, desc: "Delete records finished more than this many seconds ago" + def cleanup_preserved_jobs set_up_application! timestamp = Time.current - options[:before_seconds_ago] ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { before_seconds_ago: options[:before_seconds_ago], timestamp: timestamp }) do |payload| @@ -53,9 +57,13 @@ end no_commands do def set_up_application! require RAILS_ENVIRONMENT_RB + return unless defined?(GOOD_JOB_LOG_TO_STDOUT) && GOOD_JOB_LOG_TO_STDOUT && !ActiveSupport::Logger.logger_outputs_to?(GoodJob.logger, STDOUT) + + GoodJob::LogSubscriber.loggers << ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) + GoodJob::LogSubscriber.reset_logger end end end end