Skip to content

Commit

Permalink
Merge pull request #395 from ferocia/dtcristo/diable-listen-on-cli
Browse files Browse the repository at this point in the history
Allow que to be started without listen/notify
  • Loading branch information
oeoeaio committed Oct 16, 2023
2 parents 4e08e84 + 2593d92 commit d58b3f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/que/command_line_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]',
Expand Down
9 changes: 8 additions & 1 deletion spec/que/command_line_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d58b3f4

Please sign in to comment.