Skip to content

Instantly share code, notes, and snippets.

@sankalpk
Created February 3, 2023 13:11
Show Gist options
  • Save sankalpk/6fa164c0f80cdc77b739134dcb120570 to your computer and use it in GitHub Desktop.
Save sankalpk/6fa164c0f80cdc77b739134dcb120570 to your computer and use it in GitHub Desktop.
Resque Jobs

Documentation is actually decent here:

resque/resque.rb at master · resque/resque

Jira ticket:

https://goatapp.atlassian.net/browse/CSV-10189

You can run console commands using the terminal. For example, running the following from the sneakers directory will allow you to work in the Rails console in the qa environment :

bin/aws qa run

Initialize a worker queue locally:

QUEUE=vacation_mode rake resque:work

Get a list of Resque workers:

Resque.workers

Get general stats:

Resque.info

Reset number of processed jobs. This might help you calculate number of downstream jobs created for a given task:

Resque.redis.set "stat:processed", 0

Get a list of queues:

Resque.queues

Get list of how many jobs are currently in each queue:

Resque.queue_sizes

Get the numbers jobs in a specific queue:

Resque.redis.llen("queue:<queue_name>")

Get the number of workers for a given queue (note that the worker may be processing multiple queues):

Resque.workers.select {|w| w.queues.include?("queue_name")}.size

Create 20 fake products to test a power seller and enqueue the job:

user = User.first
FactoryBot.create_list(:product, 20, warehouse_id: 10, user: user)
Resque.enqueue(Users::VacationMode, user.id, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment