Determine the number of current Resque employees from a Rails application

In my Rails application, I would like to open a window showing the number of Resque workers currently running. Basically it will be such that I can warn users when there are no workers.

I have a Resque admin application also installed in routes.rb:

mount Resque::Server, :at => "/admin/resque" 

I see that there is a text file called /admin/resque/stats.txt , which includes the following:

 resque.pending=0 resque.processed+=8 resque.failed+=0 resque.workers=2 resque.working=0 queues.model_job_queue=0 

Should I extract this file and just resque.workers it for resque.workers value or is there another, better method?

+4
source share
1 answer

I would ask Resque directly for the workers array and count the returned items.

 1.9.2-p290 :003 > Resque.workers.count => 12 

This is how resque gets the counter to build /resque/stats.txt .

Hope this helps.

+5
source

Source: https://habr.com/ru/post/1386199/


All Articles