简体   繁体   English

如何查看Resque作业

[英]How to view a Resque job

On our Rails application, we use Resque to process background jobs (we also use Resque Scheduler and Resque Status). 在我们的Rails应用程序中,我们使用Resque处理后台作业(我们还使用Resque Scheduler和Resque Status)。

We're getting jobs in the queue that aren't being processed, however I can't see any details about them. 我们正在队列中找到未处理的作业,但是我看不到有关它们的任何细节。

If I use redis-cli - I can pull up job details: 如果我使用redis-cli - 我可以提取工作细节:

get "resque:status:bd2209c9......"

Which will show the timestamp, what queue it's in, it's uuid and any parameters, but not the class name. 这将显示时间戳,它所在的队列,它是uuid和任何参数,但不是类名。 If I do the same on a job that has been run, then I can see the class name, messages etc. 如果我在已经运行的工作上做同样的事情,那么我可以看到类名,消息等。

So is there a way that I can find the class name for a job that is waiting to be run. 那么有没有办法可以找到等待运行的作业的类名。

Thanks. 谢谢。

So after some digging: 经过一番挖掘后:

  • All of the Resque jobs are sitting in a Redis list for each queue 所有Resque作业都位于每个队列的Redis列表中
  • There isn't really a way of getting at the elements of the list using their uuid 实际上没有办法使用他们的uuid来获取列表的元素

Although you can look at the entire list (or a subset): 虽然您可以查看整个列表(或子集):

# This works for Resque 1.25.0
Resque.redis.lrange('queue:QUEUE_NAME', 0, -1)

Which will return an array of strings (encoded JSON). 这将返回一个字符串数组(编码的JSON)。 To decode the first item: 要解码第一个项目:

job = Resque.redis.lrange('queue:QUEUE_NAME', 0, 0).first
h = Resque.decode(job)

Which will then give you a hash to play with, but looking at the list was enough to see the class name. 然后会给你一个哈希值,但查看列表就足以看到类名了。 It helped that the queue I was looking at was pretty small. 它帮助我看到的队列非常小。

There may be a better way at finding this out, but this worked for me. 找到这个可能有更好的方法,但这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM