简体   繁体   中英

How do I inspect what was the last failed job in Resque?

I know it returns a hash, but its strange how the syntax goes.. I'm trying to find out what the last one is.

If I do this :

Resque.info[:failed] # -> 68

So assuming there's 68 failed jobs, when I do this :

Resque::Failure.all()

It only returns one job ( I believe its the first job ).

I think this is just a syntactical error on my part. Because I've also seen this :

Resque::Failure.all(0, 20)

Which I believe would pull an array of indices between 0 and 20.

So.. anyone know the syntactical clause to pull just the last failed job?

as said here with all you will give 1st param as the start point and second param as the number of results.

Resque::Failure.all(0, 1)

is the correct syntax to get the last failure, if they are ordered DESC

EDIT:

They are ordered ASC, so:

Resque::Failure.all((Resque::Failure.count - 1), 1)

There is also another way to see resque job information. Resque comes with a Sinatra-based front end for seeing what's up with your queue. 在此处输入图片说明

Here you will get detail information. Hope this will help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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