gpt4 book ai didi

ruby-on-rails - 如果我使用 w.keepalive,God Gem 会开始监视,但如果我使用 $god sidekiq start 则不会

转载 作者:数据小太阳 更新时间:2023-10-29 08:12:57 32 4
gpt4 key购买 nike

我正在努力使用 SidekiqGod Gem旁边.我希望能够使用 $god start sidekiq 手动启动 sidekiq 进程,但这无法启动该进程。如果我设置 w.keepalive(在下面的代码中注释掉),我只能让它启动 sidekiq 进程。

我使用以下命令启动 God:$ god -c "./config.god"-D --log-level info,在前台启动 god,得到以下输出:

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 的日志中没有任何内容,而且我可以清楚地看到没有 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

最佳答案

试试这个:

# 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

关于ruby-on-rails - 如果我使用 w.keepalive,God Gem 会开始监视,但如果我使用 $god sidekiq start 则不会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14464934/

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