Ruby-on-rails 如何查看延迟的作业队列?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18563579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I see the delayed job queue?
提问by knotito
I wonder if I succeeded to get Delayed::Jobworking.
Can't see jobs in the delayed_jobstable.
我想知道我是否成功让Delayed::Job工作。看不到delayed_jobs表中的作业。
- Is that normal?
- Is there any other ways too see job queue?
- 这是正常的吗?
- 还有其他方法可以查看作业队列吗?
回答by Nicolas Garnil
DelayedJob stores a database record for each enqueued job so you can retrieve them directly through the rails console (assuming you are using ActiveRecord or similar).
DelayedJob 为每个排队的作业存储一个数据库记录,以便您可以直接通过 rails 控制台检索它们(假设您使用的是 ActiveRecord 或类似的)。
Open the rails console:
打开 Rails 控制台:
$ rails c
and then query the enqueued jobs:
然后查询排队的作业:
$ Delayed::Job.all
or
或者
$ Delayed::Job.last
Check out the documentation.
查看文档。
If you installed delayed_job with another database like Redis you may want to go and check in there the queued jobs.
如果您使用另一个数据库(如 Redis)安装了 delay_job,您可能想要去那里检查排队的作业。
回答by pdobb
You should see jobs in the delayed_jobs table, yes. But when delayed jobs are run successfully they're deleted. So it may just be a fleeting thing. (Delayed Job checks the table for new jobs to run every 5 seconds, so the record may only last a few seconds on average given a short-running job.) I usually make sure the delayed job daemon is turned off if I want to inspect the payload objects in the delayed_jobs table.
您应该会在 delay_jobs 表中看到作业,是的。但是当延迟的作业成功运行时,它们会被删除。所以这可能只是转瞬即逝的事情。(延迟作业每 5 秒检查一次表中是否有新作业运行,因此对于短期运行的作业,该记录可能平均只持续几秒钟。)如果我想检查,我通常确保关闭延迟作业守护程序delay_jobs 表中的有效负载对象。

