运行god.rb来启动和监控Sidekiq这不起作用。在我的sidekiq的上帝配置下面。
在生产终端上手动运行sidekiq -C /srv/book/current/ config / fine kiq.yml确实工作得很好,但sidekiq god.rb配置不是这样的。有人知道为什么会发生这种情况吗?日志里没写太多。
God.watch do |w|
w.name = "sidekiq"
w.interval = 30.seconds
w.start = "cd #{ENV['RAILS_ROOT']}; sidekiq -C /srv/books/current/config/sidekiq.yml"
w.stop = "cd #{ENV['RAILS_ROOT']}; exec sidekiqctl stop /srv/books/shared/tmp/pids/sidekiq.pid"
w.restart = "#{w.stop} && #{w.start}"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.log = File.join(ENV['RAILS_ROOT'], 'log', '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
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
# Notifications
# --------------------------------------
w.transition(:up, :start) do |on|
on.condition(:process_exits) do |p|
p.notify = 'ect'
end
end
end发布于 2013-07-29 06:39:29
您似乎缺少RAILS_ROOT定义。您可以在脚本中使用它,但它从未定义过。它可能在终端中工作,因为它被设置在那里。但是当god.rb运行它时,你得到的不是终端环境,而是一个新的干净的环境。
尝试将以下内容添加到您的上帝脚本中:
w.env = { 'RAILS_ROOT' => "/srv/books/current",
'RAILS_ENV' => "production" }你也可以将它设置为一个普通的拼音变量,如the example所示。
https://stackoverflow.com/questions/15098967
复制相似问题