gpt4 book ai didi

ruby-on-rails-3 - sidekiq true god.rb 从不运行我的 worker ,而来自终端的相同命令呢?

转载 作者:IT王子 更新时间:2023-10-29 06:02:34 26 4
gpt4 key购买 nike

运行 god.rb 来启动和监控 Sidekiq 这不起作用。在我的 sidekiq 神配置下。

在生产环境中从终端手动运行 sidekiq -C/srv/books/current/config/sidekiq.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

最佳答案

您似乎缺少 RAILS_ROOT 定义。您在脚本中使用它,但它从未被定义。它可能在终端中工作,因为它设置在那里。但是当 god.rb 运行它时,你得到的不是终端环境,而是一个干净的新环境。

尝试将此添加到您的上帝脚本中:

w.env = { 'RAILS_ROOT' => "/srv/books/current",
'RAILS_ENV' => "production" }

您也可以将其设置为普通的 ruby​​ 变量,如 the example 所示。 .

关于ruby-on-rails-3 - sidekiq true god.rb 从不运行我的 worker ,而来自终端的相同命令呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15098967/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com