2

我一直在寻找如何使用上帝监控系统启动sidekiq的配置。下面是我用来启动 sidekiq 的神文件。

rails_env = ENV['RAILS_ENV'] || "production"
rails_root = ENV['RAILS_ROOT'] || "/home/ubuntu/Projects/app"

God.watch do |w|
  w.dir      = "#{rails_root}"
  w.name     = "sidekiq"
  w.interval = 30.seconds
  w.env      = {"RAILS_ENV" => rails_env}
  w.interval = 30.seconds
  w.start = "/home/ubuntu/.rvm/gems/ruby-1.9.3-p0/bin/ruby -f #{rails_root}/ sidekiq -c 25 -q worker,15 -q distributor,5"

  w.uid = 'ubuntu'

  # 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

  # determine when process has finished starting
  w.transition([:start, :restart], :up) do |on|
    on.condition(:process_running) do |c|
      c.running = true
      c.interval = 5.seconds
    end

    # failsafe
    on.condition(:tries) do |c|
      c.times = 5
      c.transition = :start
      c.interval = 5.seconds
    end
  end

  # start if process is not running
  w.transition(:up, :start) do |on|
    on.condition(:process_running) do |c|
      c.running = false
    end
  end
end

当我使用命令运行此脚本时god,上帝服务器“显示进程未运行”,就好像什么都没发生一样。我相信我没有w.start正确调用sidekiq,

bundle exec sidekiq -c 25 -q worker,15 -q distributor,5在开发模式下使用,它工作正常。

我错过了什么?是否有不同的方式来部署 sidekiq 工作人员?

4

3 回答 3

1

对我来说解决“进程未运行”问题的关键是正确定义dir属性:

w.dir = "#{Rails.root}"

这解决了问题。

于 2014-07-16T10:06:51.623 回答
0

I faced similar issues. Specifying queue and concurrency settings under sidekiq.yml solved it for me. In your god start,

sidekiq -e #{env} -C #{root}/config/sidekiq.yml

The Sidekiq Github has an example of the yml config. It goes something like:

---
:concurrency: 25
:queues:
  - [a, 5]
  - [b, 3]
  - [c, 2]
  - [default, 3]

I hope you have already found a solution though.

于 2012-08-21T09:43:43.370 回答
-1

我刚刚使用您的代码部署了我自己的 God/sidekiq 设置,而这个更改让它对我有用。我将您的替换w.start为:

w.start = "bundle exec sidekiq -q release,1 -q artist,2 -q artists,3 -c 20"

(当然,这些队列只是我碰巧使用的队列,并不相关)

于 2012-07-17T16:00:34.253 回答