【问题标题】:How to monitor background jobs in production, queue_classic如何监控生产中的后台作业,queue_classic
【发布时间】:2014-03-04 11:53:53
【问题描述】:

我正在使用 queue_classic 进行后台作业,
我需要监控生产中的后台作业,即启动、停止等。
我找到了similar question,但对我没有帮助
我也找到了神码:
但我将如何停止、重启工作人员?

number_queues.times do |queue_num|
  God.watch do |w|
    w.name = "QC-#{queue_num}"
    w.group = "QC"
    w.interval = 5.minutes
    w.start = "bundle exec rake queue:work" # This is your rake task to start QC listening
    w.gid = 'nginx' 
    w.uid = 'nginx'
    w.dir = rails_root
    w.keepalive
    w.env = {"RAILS_ENV" => rails_env} 
    w.log = "#{log_dir}/qc.stdout.log"  # Or....    "#{log_dir}//qc-#{queue_num}.stdout.log"

    # determine the state on startup
    w.transition(:init, { true => :up, false => :start }) do |on|
      on.condition(:process_running) do |c|
        c.running = true
      end
    end
  end
end

更新
此代码似乎不起作用

namespace :queue_classic do
  desc "Start QC worker"
  task :start, roles: :web do
    run "cd #{release_path} && RAILS_ENV=production bundle exec rake qc:work"
  end
  after "deploy:restart", "queue_classic:restart"
end

【问题讨论】:

    标签: ruby-on-rails backgroundworker queue-classic


    【解决方案1】:

    正如documentation 中所说,您可以通过发出来重新启动您的工作人员

    god restart QC-<worker_number>
    

    QC-&lt;worker_number&gt; 是您分配给工作人员的名称

    【讨论】:

      【解决方案2】:

      根据您需要的监控类型,您还可以查看Toro,它提供了大量的监控,无论是在 Web 界面中,还是通过作业存储大量数据并且可以轻松地使用 ActiveRecord 查询进行查询。 Toro 还支持中间件,这可能对您的需求有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-14
        • 2016-02-21
        • 1970-01-01
        • 2016-10-10
        • 2017-01-01
        • 2015-01-16
        • 1970-01-01
        • 2016-05-09
        相关资源
        最近更新 更多