首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不识别resque worker是否已启动

不识别resque worker是否已启动
EN

Stack Overflow用户
提问于 2012-08-23 18:00:43
回答 2查看 357关注 0票数 2

我在运行来自上帝的resque工人时遇到了问题。

这是我的上帝配置

代码语言:javascript
复制
num_workers = 9 
queue       = '*'
current_path = "/u/apps/narg/current"

God.pid_file_directory = "/u/apps/narg/current/tmp/pids"
num_workers.times do |num|
  God.watch do |w|
    w.name     = "resque-#{num}"
    w.group    = "resque_all"
    w.interval = 30.seconds
    w.env      = {"QUEUE"=>queue, "RAILS_ENV"=>"production",
             'PIDFILE' => "#{current_path}/tmp/pids/#{w.name}.pid" }
w.start    = "cd #{current_path} ; bundle exec rake environment resque:work"
w.log      = "#{current_path}/log/god-#{w.name}.log"
w.pid_file = "#{current_path}/tmp/pids/#{w.name}.pid"
w.uid = 'root'
w.gid = 'root'
w.behavior(:clean_pid_file)
# retart if memory gets too high
w.transition(:up, :restart) do |on|
  on.condition(:memory_usage) do |c|
    c.above = 150.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
    c.interval = 5
  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

当我启动上帝时,当工人们都在工作时,一切看起来都很好,并且它运行所有的转换到: up。

但当工作进程不运行时,它会在启动后停止。工作进程实际启动了,pid文件也是正确的。只有上帝不明白:

代码语言:javascript
复制
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 move 'unmonitored' to 'init'
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 moved 'unmonitored' to 'init'
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 [trigger] process is not running (ProcessRunning)
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 move 'init' to 'start'
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 before_start: deleted pid 
 ** [out :: narg-wrk02] I [2012-08-23 11:40:48]  INFO: resque-7 start: cd /u/apps/narg/current ; bundle exec rake environment resque:work

如前所述,工作人员已经启动,并且运行良好。此外,pid文件还包含正确的pid。

如果我现在杀死上帝并重新启动它,它会识别运行中的工作进程,并转换为:up..

有什么想法或建议吗?

EN

回答 2

Stack Overflow用户

发布于 2014-01-27 06:08:09

试着改变

w.start = "cd #{current_path} ; bundle exec rake environment resque:work"

w.start = "cd #{current_path} ; bundle exec rake environment resque:work &"

这为我解决了同样的问题。

票数 0
EN

Stack Overflow用户

发布于 2016-03-09 11:27:07

我用以下命令修复了同样的问题:

代码语言:javascript
复制
w.start = "cd #{current_path} && rake environment RAILS_ENV=production resque:work &"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12089211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档