Reputation: 93
In Rails we can get the workers infor easily. I used resque-schedule for delayed Job purpose and now I want to fetch all delayed job list via rails console.
Upvotes: 0
Views: 32
Reputation: 93
I find out the solution and it helpful for me
Resque.delayed_queue_peek(1, 20)
# Result : ["1727744400", "1727780400", "1728379910", "1728381061", "1728381063", "1728381750", "1728383426", "1728391401", "1728391426", "1730320200", "1731148380", "1737030600"]
scheduled_timestamps = Resque.redis.zrange('delayed_queue_schedule', 0, -1)
# result ["1727744400", "1727780400", "1728379910", "1728381061", "1728381063", "1728381750", "1728383426", "1728391401", "1728391426", "1730320200", "1731148380", "1737030600"]
scheduled_jobs = scheduled_timestamps.map do |timestamp|
jobs = Resque.redis.lrange("delayed:#{timestamp}", 0, -1)
jobs.map do |job|
{ job: job, next_run_time: Time.at(timestamp.to_i) }
end
end
# result [["{\"class\":\"CompanyEnqueSnapshotsJob\",\"args\":[1,\"2024-10-01\"],\"queue\":\"snapshots\"}", :next_run_time=>"2024-10-01 06:30:00 +0530"]...
scheduled_jobs.flatten.each do |job|
puts job
end
{"class":"CompanyEnqueSnapshotsJob","args":[1,"2024-10-01"],"queue":"snapshots"}
Thank you
Upvotes: 0