ruby-on-rails - Rails 服务器启动时如何运行 "rake resque:work QUEUE=*"?

标签 ruby-on-rails ruby-on-rails-3 rake resque

我已正确安装 resque,但要处理我需要运行的所有队列

rake resque:work QUEUE='*'

问题是我需要保持终端窗口打开,否则 resque:work 将不起作用。

您知道每次运行“rails server”时自动运行该 rake 命令的方法吗?

我在 本地主机

lib/tasks/resque.rake
require 'resque/tasks'

task "resque:setup" => :environment do
    ENV['QUEUE'] = "*"
end

最佳答案

您可以使用像 foreman 这样的 gem,而不是调用 invoke 函数。可以调用所有其他任务。
如果您希望拥有一个主要是平台中立的解决方案,并且在部署到云中时,这将非常有用。
您的 Procfile 可以包含以下内容:

web:    bundle exec thin start -p $PORT
worker: bundle exec rake resque:work QUEUE=*
clock:  bundle exec rake resque:scheduler

来源:introduction to foreman .

现在要启动服务器,您只需要发出 foreman start 命令,该命令会 fork 子线程来执行单独的工作。

关于ruby-on-rails - Rails 服务器启动时如何运行 "rake resque:work QUEUE=*"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13326843/

相关文章:

ruby-on-rails - 编写 Rails 编码标准的好例子?

javascript - Coffeescript - 如何在 ruby​​ on rails 中将 javascript 转换为 coffeescript?

ruby-on-rails - Rails : How to write to a custom log file from within a rake task in production mode?

ruby-on-rails - 加载错误 : Could not open library 'lzo2' : lzo2: cannot open shared object file: No such file or directory

ruby-on-rails - 如何在 docker 上安装 Ruby?

ruby-on-rails - 如何安装wkhtmltopdf?

ruby - 多个 Controller 之间共享的 before_filter 放在哪里

ruby-on-rails-3 - Rails 当前页面?方法为 POST 时为 "fails"

sqlite - 使用 sqlite3 迁移时出现问题,收到错误消息-> 未定义的方法 `prerequisites' 为 nil :NilClass

ruby-on-rails - 多态关系中 nested_attributes 的翻译