Skip to content

Commit

Permalink
Configure litejob as active job adapter for dev and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed Dec 31, 2023
1 parent 6786c02 commit d753056
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/jobs/sample_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class SampleJob < ApplicationJob
def perform
Rails.logger.info "SampleJob is working!"
end
end
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

# Use a real queuing backend for Active Job (and separate queues per environment).
config.active_job.queue_adapter = :litejob
end
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "joy_production"
config.active_job.queue_adapter = :litejob

config.action_mailer.perform_caching = false

Expand Down
11 changes: 11 additions & 0 deletions config/litejob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# path: '/queue.db' # where the database file resides
queues:
- [default, 1] # default queue with the lowest priority
- [urgent, 10, spawn] # this is not a default, a higher priority queue which will run every job in its own thread or fiber
workers: 5 # how many threads/fibers to spawn for queue processing
retries: 5 # how many times to retry a failed job before giving up
retry_delay: 60 # seconds
retry_delay_multiplier: 10 # 60 -> 600 -> 6000 and so on
dead_job_retention: 864000 # 10 days to keep completely faild jobs in the _dead queue
gc_sleep_interval: 7200 # 2 hours of sleep between checking for dead jobs that are ready to be buried forever
# logger: STDOUT # possible values are STDOUT, STDERR, NULL or a file location

0 comments on commit d753056

Please sign in to comment.