chrisboulton / php-resque

PHP port of resque (Workers and Queueing)
MIT License
3.43k stars 759 forks source link

How to get workers list and their statuses #253

Closed arunp27 closed 8 years ago

arunp27 commented 9 years ago

Hi, i'm new to this PHP_resque, so please help me in this regard. Using PHP script how to get list of current running queues and job's count in each queue.

danhunsaker commented 9 years ago

I'm seeing two completely different questions, here. One in the title, and the other in the description. The answer to both (each of them actually two questions themselves) is to use Redis commands. There is a workers key that stores a list of all current workers, and then each worker manages keys under its own name that tan be used to determine its status. Similarly, there is a queues key holding the names of each queue that has been used, and then the keys for each queue (queue:{$name}) can be used to determine the size and contents of each.

Alternately, you can fire up Resque Web, part of the Ruby Resque implementation, and point it at your Redis server - the PHP port is designed to be 100% compatible with the Ruby origin. You might need to roll back to an older version, though, as Ruby's version has seen continued active development, while PHP's has not, recently.

arunp27 commented 9 years ago

sorry for that.. Thanks For your response..if you don't mind can you please tell me how to get worker's stats by PHP script.

mikehaertl commented 9 years ago

@arunp27 In the latest code Resque_Worker::all() returns a list of Resque_Worker objects. You can then call $worker->getStat('processed') and $worker->getStat('failed') on such an object to get the number of total/failed jobs respectively .

arunp27 commented 9 years ago

Thanks for the response.