Skip to content

Commit

Permalink
Merge pull request #2312 from manyfold3d/rearrange-workers
Browse files Browse the repository at this point in the history
Improve behaviour of background workers
  • Loading branch information
Floppy committed Jun 27, 2024
2 parents 3d4da80 + ced4cf3 commit afed90c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
rails: bundle exec rails server -p $PORT
worker: bundle exec sidekiq
default_worker: bundle exec sidekiq -C config/workers/default.yml
performance_worker: bundle exec sidekiq -C config/workers/performance.yml
3 changes: 2 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rails: SCOUT_DEV_TRACE=true bin/rails server -p $PORT
worker: bundle exec sidekiq
default_worker: bundle exec sidekiq -C config/workers/default.yml
performance_worker: bundle exec sidekiq -C config/workers/performance.yml
js: yarn build --watch
css: yarn build:css --watch
typecheck: yarn typecheck --watch --preserveWatchOutput
3 changes: 2 additions & 1 deletion app/jobs/analysis/file_conversion_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class NonManifoldError < StandardError
end

class Analysis::FileConversionJob < ApplicationJob
queue_as :analysis
queue_as :performance
sidekiq_options retry: false

def perform(file_id, output_format)
# Can we output this format?
Expand Down
3 changes: 2 additions & 1 deletion app/jobs/analysis/geometric_analysis_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class MeshLoadError < StandardError
end

class Analysis::GeometricAnalysisJob < ApplicationJob
queue_as :analysis
queue_as :performance
sidekiq_options retry: false

def perform(file_id)
# Get model
Expand Down
7 changes: 2 additions & 5 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
class ApplicationJob < ActiveJob::Base
include ActiveJob::Status
sidekiq_options retry: false

# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
sidekiq_options retry: 10

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
discard_on ActiveJob::DeserializationError

before_perform do |job|
begin
Expand Down
3 changes: 2 additions & 1 deletion config/sidekiq.yml → config/workers/default.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
:concurrency: <%= ENV.fetch("DEFAULT_WORKER_CONCURRENCY", 4) %>
:queues:
- scan
- default
- analysis
- default
:scheduler:
:dynamic: true
:dynamic_every: 15s
4 changes: 4 additions & 0 deletions config/workers/performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
:concurrency: <%= ENV.fetch("PERFORMANCE_WORKER_CONCURRENCY", 1) %>
:queues:
- performance

0 comments on commit afed90c

Please sign in to comment.