与神一起运行时Resque失败 - JavaScript运行时?

时间:2013-11-19 07:58:56

标签: javascript ruby resque god execjs

我正在尝试与几个Resque工作人员部署一个简单的Rails应用程序。因为我需要工人在后台奔跑,所以我正在用上帝来管理他们。从命令行运行worker时,它运行得很好:

QUEUE = * /var/www/billtune/shared/bundle/ruby/1.9.1/bin/rake -f / var / www / billtune / current / Rakefile environment rescue:work

但当他们被上帝管理时,似乎进程一直在崩溃。查看日志文件似乎与execjs有关:

rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/execjs-2.0.2/lib/execjs.rb:5:in `<module:ExecJS>'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/execjs-2.0.2/lib/execjs.rb:4:in `<top (required)>'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/var/www/billtune/shared/bundle/ruby/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/home/ec2-user/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/var/www/billtune/current/config/application.rb:7:in `<top (required)>'
/var/www/billtune/current/Rakefile:5:in `require'
/var/www/billtune/current/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

如何在上帝运行时缺少JavaScript运行时,但在直接运行时不会丢失?

为了完整起见,我还附上相关的上帝文件:

rails_env   = ENV['RAILS_ENV']  || "production"
rails_root  = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/..'
num_workers = rails_env == 'production' ? 2 : 1
puts "rails_root=" + rails_root

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"=>"*", "RAILS_ENV"=>rails_env}
    w.start    = "bundle exec rake -f #{rails_root}/Rakefile environment resque:work"
    w.log      = "#{rails_root}/log/resque-#{num}.log"
    w.err_log  = "#{rails_root}/log/resque_error-#{num}.log"

#    w.uid = 'git'
#    w.gid = 'git'

    # 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

0 个答案:

没有答案