diff --git a/app/jobs/sample_job.rb b/app/jobs/sample_job.rb new file mode 100644 index 00000000..af93fb72 --- /dev/null +++ b/app/jobs/sample_job.rb @@ -0,0 +1,5 @@ +class SampleJob < ApplicationJob + def perform + Rails.logger.info "SampleJob is working!" + end +end diff --git a/config/environments/development.rb b/config/environments/development.rb index 2e7fb486..b433c938 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/environments/production.rb b/config/environments/production.rb index b22f51fe..8a2bc639 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 diff --git a/config/litejob.yml b/config/litejob.yml new file mode 100644 index 00000000..3fafe415 --- /dev/null +++ b/config/litejob.yml @@ -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