RAILS_ENV =生产脚本/ delayed_job start(dir undefined)

时间:2012-04-24 14:45:26

标签: ruby-on-rails ruby ruby-on-rails-3 delayed-job production-environment

我实际上想在生产模式下激活延迟作业。所以我输入“

  

RAILS_ENV =生产脚本/ delayed_job start

“在控制台和 错误在“

  

:dir => File.join(dir,'tmp','pids'),

“报告未定义的目录...在线搜索原始文件但找不到任何内容。

#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config',   'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
daemon_options = {
  :multiple   => false,
  :dir_mode   => :normal,
  **:dir        => File.join(dir, 'tmp', 'pids'),**
  :backtrace  => true
}

Daemons.run_proc('job_runner', daemon_options) do
  if ARGV.include?('--')
    ARGV.slice! 0..ARGV.index('--')
  else
    ARGV.clear
  end

  Dir.chdir dir
  RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development'
  require File.join('config', 'environment')

  Delayed::Worker.new.start
 end

1 个答案:

答案 0 :(得分:0)

尝试用dir替换Rails.root(替换两次出现)。从未在上面的代码中定义变量或方法dir。您还可以在daemon_options上方定义目录:

dir = Rails.root
daemon_options = {
  ...