diff --git a/lib/que/command_line_interface.rb b/lib/que/command_line_interface.rb index dfbd22a2..9b869938 100644 --- a/lib/que/command_line_interface.rb +++ b/lib/que/command_line_interface.rb @@ -50,6 +50,14 @@ def parse( poll_interval = i end + opts.on( + '--listen [LISTEN]', + String, + "Set to false to disable listen mode (default: true)" + ) do |listen| + options[:listen] = listen != "false" + end + opts.on( '-l', '--log-level [LEVEL]', diff --git a/spec/que/command_line_interface_spec.rb b/spec/que/command_line_interface_spec.rb index 7d7c013b..7ee69c31 100644 --- a/spec/que/command_line_interface_spec.rb +++ b/spec/que/command_line_interface_spec.rb @@ -188,6 +188,7 @@ def write_file def assert_locker_instantiated( worker_priorities: [10, 30, 50, nil, nil, nil], poll_interval: 5, + listen: true, wait_period: 50, queues: ['default'], maximum_buffer_size: 8 @@ -198,7 +199,7 @@ def assert_locker_instantiated( locker_instantiate = locker_instantiates.first - assert_equal true, locker_instantiate[:listen] + assert_equal listen, locker_instantiate[:listen] assert_equal true, locker_instantiate[:poll] assert_equal queues, locker_instantiate[:queues] assert_equal poll_interval, locker_instantiate[:poll_interval] @@ -257,6 +258,12 @@ def assert_locker_started( end end + it "with --listen false to disable listen mode" do + assert_successful_invocation "./#{filename} --listen false" + assert_locker_instantiated(listen: false) + assert_locker_started + end + it "with --wait-period to configure the wait period" do assert_successful_invocation "./#{filename} --wait-period 200" assert_locker_instantiated(