【问题标题】:capistrano-resque: Multistage with Different :workerscapistrano-resque: Multistage with different :workers
【发布时间】:2014-07-11 14:43:15
【问题描述】:

我有两个生产 AWS 实例,它们将运行 resque 但侦听不同的队列。这是我当前配置的示例:

config/deploy/production/prod_resque_1.rb

server "<ip>", :web, :app, :resque_worker, :db, primary: true

set :resque_log_file, "log/resque.log"
set :resque_environment_task, true

set :workers, {
  "queue1" => 5,
  "*" => 2
}

after "deploy:restart", "resque:restart"

config/deploy/production/prod_resque_2.rb

server "<ip>", :web, :app, :resque_worker, :db, primary: true

set :resque_log_file, "log/resque.log"
set :resque_environment_task, true

set :workers, {
  "queue2,queue3,queue4" => 5
}

after "deploy:restart", "resque:restart"

然后,我有一个“全局”配方:

load 'config/deploy/production/common'
load 'config/deploy/production/prod_resque_1'
load 'config/deploy/production/prod_resque_2'

明显的问题是,当我调用cap prod_resque resque:start 时,prod_resque_1 中的:workers 定义被prod_resque_2 的负载覆盖,导致prod_resque_1prod_resque_2 都有工作人员在听@仅限 987654330@、queue3queue4

我的工作是先运行cap prod_resque_1 resque:start,然后运行cap prod_resque_2 resque:start,但这违背了capistrano的目的。

关于更清洁的解决方案的任何建议,允许我运行 cap prod_resque resque:start 并让“第一个”服务器运行 7 个工作人员、5 个监听 queue1 和 2 个监听所有队列,以及运行 5 个工作人员的“第二个”服务器,只听queue2queue3queue4

【问题讨论】:

    标签: ruby-on-rails ruby capistrano resque


    【解决方案1】:

    capistrano-resque docs 中给出了一个示例:如果您为每个服务器(或服务器组)分配不同的角色,那么您可以基于每个角色定义工作人员。

    在你的情况下,你会做类似的事情

    role :queue_one_workers, [ip_from_prod_resque_1]
    role :other_queue_workers, [ip_from_prod_resque_2]
    
    set :workers, {
      :queue_one_workers   => {"queue1" => 5, "*" => 2},
      :other_queue_workers => {"queue2" => 5, "queue3" => 5, "queue4" => 5}
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-03
      • 1970-01-01
      • 1970-01-01
      • 2021-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-26
      相关资源
      最近更新 更多