resque工作人员在启动后不久退出,没有输出

时间:2014-02-04 19:35:27

标签: ruby-on-rails-4 resque god

我正在努力让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每隔几秒退出一次。我没有日志输出,没有错误,没有。

1 个答案:

答案 0 :(得分:0)

我在开发环境中遇到同样的问题,正在运行

QUEUE=* bundle exec rake resque:work

只会退出命令行。我不得不用VVERBOSE = 1运行来计算发生了什么。对我来说,我得到以下错误:

Failed to start worker : #<NoMethodError: undefined method `auto_flushing=' for #<ActiveSupport::Logger:0x00000108908ab8>>

事实证明,在我们的项目中

Resque.before_first_fork = Proc.new { Rails.logger.auto_flushing = 1 }

在我们的resque.rake文件中,在resque:setup任务中。