3

God Gemと一緒にSidekiqを使用するのに苦労しています。を使用して sidekiq プロセスを手動で開始できるようにしたいのですが、プロセスの開始に失敗します。w.keepalive を設定した場合にのみ、sidekiq プロセスを開始できます (以下のコードでコメントアウトされています)。$god start sidekiq

私は God を使用して起動しています: を使用して$ god -c "./config.god" -D --log-level info、神をフォアグラウンドで起動すると、次の出力が得られます。

I [2013-01-22 17:46:00]  INFO: Started on drbunix:///tmp/god.17165.sock
I [2013-01-22 17:46:00]  INFO: sidekiq move 'unmonitored' to 'up'
I [2013-01-22 17:46:00]  INFO: sidekiq moved 'unmonitored' to 'up'

私が得る使用$god start sidekiq

Sending 'start' command

The following watches were affected:
  sidekiq

しかし、神からの出力は得られず、sidekiq のログには何も書き込まれません$ ps auxwww | grep sidekiq

# config.god

PROJECT_ROOT = ENV['PROJECT_ROOT'] || File.dirname(__FILE__) # Dir containing this file

# Sidekiq Process

God.watch do |w|
  w.name = "sidekiq"
  w.group = "conversion"
  w.dir = PROJECT_ROOT
  w.interval = 20.seconds
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  w.behavior(:clean_pid_file)
  # w.keepalive
  w.start = "bundle exec sidekiq -v -C #{File.join(PROJECT_ROOT, 'config.yml')}"
  w.stop = "bundle exec sidekiqctl stop '/Users/me/.god/pids/sidekiq.pid' 5"

  w.log = File.join(PROJECT_ROOT, 'log/god_sidekiq.log')

end
4

1 に答える 1

0

これを試して:

# config.god

PROJECT_ROOT = ENV['PROJECT_ROOT'] || File.dirname(__FILE__) # Dir containing this file

# Sidekiq Process
pid_file = '/Users/me/.god/pids/sidekiq.pid'
God.watch do |w|
  w.name = "sidekiq"
  w.group = "conversion"
  w.dir = PROJECT_ROOT
  w.interval = 20.seconds
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  w.pid_file = pid_file
  w.behavior(:clean_pid_file)

  w.start = "cd #{PROJECT_ROOT}; bundle exec sidekiq -v -C #{File.join(PROJECT_ROOT, 'config.yml')} -P #{pid_file}&"
  w.stop = "cd #{PROJECT_ROOT}; bundle exec sidekiqctl stop #{pid_file} 5"

  w.log = File.join(PROJECT_ROOT, 'log/god_sidekiq.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

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

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

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

  # lifecycle
  w.lifecycle do |on|
    on.condition(:flapping) do |c|
      c.to_state = [:start, :restart]
      c.times = 5
      c.within = 5.minute
      c.transition = :unmonitored
      c.retry_in = 10.minutes
      c.retry_times = 5
      c.retry_within = 2.hours
    end
  end
end
于 2015-02-03T18:03:29.393 に答える