diff --git a/lib/solid_queue/configuration.rb b/lib/solid_queue/configuration.rb index bd238dcc..c9e44901 100644 --- a/lib/solid_queue/configuration.rb +++ b/lib/solid_queue/configuration.rb @@ -141,8 +141,8 @@ def dispatchers_options def recurring_tasks @recurring_tasks ||= recurring_tasks_config.map do |id, options| - RecurringTask.from_configuration(id, **options) - end + RecurringTask.from_configuration(id, **options) if options.has_key?(:schedule) + end.compact end def processes_config diff --git a/test/dummy/config/recurring_with_production_only.yml b/test/dummy/config/recurring_with_production_only.yml new file mode 100644 index 00000000..6d71dc1e --- /dev/null +++ b/test/dummy/config/recurring_with_production_only.yml @@ -0,0 +1,6 @@ +production: + periodic_store_result: + class: StoreResultJob + queue: default + args: [ 42, { status: "custom_status" } ] + schedule: every second diff --git a/test/unit/configuration_test.rb b/test/unit/configuration_test.rb index 87b8726e..11653c25 100644 --- a/test/unit/configuration_test.rb +++ b/test/unit/configuration_test.rb @@ -99,6 +99,10 @@ class ConfigurationTest < ActiveSupport::TestCase assert SolidQueue::Configuration.new(recurring_schedule_file: config_file_path(:empty_recurring)).valid? assert SolidQueue::Configuration.new(skip_recurring: true).valid? + configuration = SolidQueue::Configuration.new(recurring_schedule_file: config_file_path(:recurring_with_production_only)) + assert configuration.valid? + assert_processes configuration, :scheduler, 0 + # No processes configuration = SolidQueue::Configuration.new(skip_recurring: true, dispatchers: [], workers: []) assert_not configuration.valid?