我正在努力让 resque 在生产中工作。我有以下神文件:
rails_env = ENV['RAILS_ENV'] || "production"
rails_root = ENV['RAILS_ROOT'] || "/home/rails/current"
num_workers = rails_env == 'production' ? 5 : 2
num_workers.times do |num|
God.watch do |w|
w.dir = "#{rails_root}"
w.name = "resque-#{num}"
w.group = 'resque'
w.interval = 30.seconds
w.env = {"QUEUE"=>"add_feed,update_all,update_feed", "RAILS_ENV"=>rails_env}
w.start = "rake -f #{rails_root}/Rakefile environment resque:work"
w.log = "#{rails_root}/log/#{w.name}.log"
w.uid = 'rails'
w.gid = 'rails'
# restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 350.megabytes
c.times = 2
end
end
# 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
end
但是当我尝试运行上帝时,我得到以下输出:
root@pocketrss:~# god -c /home/rails/current/config/resque.god -D
I [2014-02-04 19:33:23] INFO: Loading /home/rails/current/config/resque.god
I [2014-02-04 19:33:23] INFO: Syslog enabled.
I [2014-02-04 19:33:23] INFO: Using pid file directory: /var/run/god
I [2014-02-04 19:33:24] INFO: Started on drbunix:///tmp/god.17165.sock
I [2014-02-04 19:33:24] INFO: resque-0 move 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-1 move 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-2 move 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-3 move 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-4 move 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-4 moved 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-3 moved 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-2 moved 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-1 moved 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-0 moved 'unmonitored' to 'init'
I [2014-02-04 19:33:24] INFO: resque-0 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:24] INFO: resque-0 move 'init' to 'start'
I [2014-02-04 19:33:24] INFO: resque-0 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:24] INFO: resque-2 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:24] INFO: resque-1 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:24] INFO: resque-3 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:24] INFO: resque-4 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:24] INFO: resque-1 move 'init' to 'start'
I [2014-02-04 19:33:24] INFO: resque-4 move 'init' to 'start'
I [2014-02-04 19:33:24] INFO: resque-3 move 'init' to 'up'
I [2014-02-04 19:33:24] INFO: resque-4 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:24] INFO: resque-2 move 'init' to 'up'
I [2014-02-04 19:33:24] INFO: resque-3 moved 'init' to 'up'
I [2014-02-04 19:33:24] INFO: resque-1 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:24] INFO: resque-2 moved 'init' to 'up'
I [2014-02-04 19:33:25] INFO: resque-0 moved 'init' to 'start'
I [2014-02-04 19:33:25] INFO: resque-0 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:25] INFO: resque-0 move 'start' to 'up'
I [2014-02-04 19:33:25] INFO: resque-0 moved 'start' to 'up'
I [2014-02-04 19:33:25] INFO: resque-4 moved 'init' to 'start'
I [2014-02-04 19:33:25] INFO: resque-4 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:25] INFO: resque-4 move 'start' to 'up'
I [2014-02-04 19:33:25] INFO: resque-4 moved 'start' to 'up'
I [2014-02-04 19:33:25] INFO: resque-1 moved 'init' to 'start'
I [2014-02-04 19:33:25] INFO: resque-1 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:25] INFO: resque-1 move 'start' to 'up'
I [2014-02-04 19:33:25] INFO: resque-1 moved 'start' to 'up'
I [2014-02-04 19:33:54] INFO: resque-3 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:54] INFO: resque-3 move 'up' to 'start'
I [2014-02-04 19:33:54] INFO: resque-3 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:54] INFO: resque-2 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:54] INFO: resque-2 move 'up' to 'start'
I [2014-02-04 19:33:54] INFO: resque-2 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:54] INFO: resque-3 moved 'up' to 'start'
I [2014-02-04 19:33:54] INFO: resque-3 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:54] INFO: resque-3 move 'start' to 'up'
I [2014-02-04 19:33:54] INFO: resque-3 moved 'start' to 'up'
I [2014-02-04 19:33:54] INFO: resque-2 moved 'up' to 'start'
I [2014-02-04 19:33:54] INFO: resque-2 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:54] INFO: resque-2 move 'start' to 'up'
I [2014-02-04 19:33:54] INFO: resque-2 moved 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-0 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-0 move 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-0 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:55] INFO: resque-4 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-4 move 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-4 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:55] INFO: resque-1 [trigger] process is not running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-1 move 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-1 start: rake -f /home/rails/current/Rakefile environment resque:work
I [2014-02-04 19:33:55] INFO: resque-4 moved 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-4 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-4 move 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-4 moved 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-0 moved 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-0 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-0 move 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-0 moved 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-1 moved 'up' to 'start'
I [2014-02-04 19:33:55] INFO: resque-1 [trigger] process is running (ProcessRunning)
I [2014-02-04 19:33:55] INFO: resque-1 move 'start' to 'up'
I [2014-02-04 19:33:55] INFO: resque-1 moved 'start' to ‘up'
基本上,resque 每隔几秒钟就会退出一次。我没有日志输出,没有错误,什么都没有。