查看当前是否正在运行特定的 rake 任务 [英] Find out whether specific rake task is currently running

查看:64
本文介绍了查看当前是否正在运行特定的 rake 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以找出当前是否正在从 Rails 控制器运行特定的 rake 任务?我有一个广泛的耙子任务,需要 5-6 个小时才能完成.

Is there any way to find out whether particular rake task is currently running from Rails controller for example? I have an extensive rake task, which takes 5-6 hours to finish.

我需要从前端 Web 界面查看该 rake 任务的状态,例如:

I need to see status of that rake task from frontend web interface, like:

  • 任务一些操作"正在运行...

此外,如果能够从前端 Web 界面中硬停止/运行该 rake 任务,那就太好了.

Also it would be nice to be able to hard stop / run that rake task from within frontend web interface.

如果发现 Railscast 专门用于它,但那里描述的方法只允许从控制器运行 rake 任务,但不停止/查看其状态.

If found Railscast devoted to it, but the method described there allows only to run rake task from controller, but not to stop/see its status.

推荐答案

如果您的工作需要 5-6 个小时才能完成,您必须在后台运行它.要在后台运行长时间运行的作业,您可以使用以下其中一种:

If your job is taking 5-6 hours to complete, you must run it in background. To run long running jobs in background you can use one of these:

  1. Resque
  2. Sidekiq

为了跟踪您的工作状态,您可以使用相应的状态跟踪宝石:

And for tracking status of your jobs, you can use corresponding status tracking gems:

  1. ResqueStatus
  2. SidekiqStatus

就我个人而言,我更喜欢 sidekiq 的效率.

Personally, I prefer sidekiq for its efficiency.

注意:上面提到的所有 gem 都有足够好的文档.请参考那些.

NOTE: All the above mentioned gems has good enough docs. Kindly refer to those.

这篇关于查看当前是否正在运行特定的 rake 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆