Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly configure worker sleep delay #4149

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/cloud_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ system_hostnames:
jobs:
global:
timeout_in_seconds: 14400
worker_sleep_delay_in_seconds: 5
queues: {}

app_usage_events:
Expand Down
5 changes: 4 additions & 1 deletion lib/cloud_controller/config_schemas/base/api_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ class ApiSchema < VCAP::Config
default_app_ssh_access: bool,

jobs: {
global: { timeout_in_seconds: Integer },
global: {
timeout_in_seconds: Integer,
worker_sleep_delay_in_seconds: Integer
},
queues: {
optional(:cc_generic) => { timeout_in_seconds: Integer }
},
Expand Down
5 changes: 4 additions & 1 deletion lib/cloud_controller/config_schemas/base/worker_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ class WorkerSchema < VCAP::Config
default_app_ssh_access: bool,

jobs: {
global: { timeout_in_seconds: Integer },
global: {
timeout_in_seconds: Integer,
worker_sleep_delay_in_seconds: Integer
},
queues: {
optional(:cc_generic) => { timeout_in_seconds: Integer }
},
Expand Down
1 change: 1 addition & 0 deletions lib/delayed_job/delayed_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_initialized_delayed_worker(config, logger)
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = config.get(:jobs, :global, :timeout_in_seconds) + 1
Delayed::Worker.sleep_delay = config.get(:jobs, :global, :worker_sleep_delay_in_seconds)
Delayed::Worker.logger = logger

unless @queue_options[:num_threads].nil?
Expand Down
1 change: 1 addition & 0 deletions spec/unit/lib/delayed_job/delayed_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
expect(Delayed::Worker.destroy_failed_jobs).to be false
expect(Delayed::Worker.max_attempts).to eq(3)
expect(Delayed::Worker.max_run_time).to eq(14_401)
expect(Delayed::Worker.sleep_delay).to eq(5)
end

context 'when the number of threads is specified' do
Expand Down
Loading