2
votes

I actually want to activate delayed job on production mode. So I type in "

RAILS_ENV=production script/delayed_job start

" at console and Having the error at "

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

" that report undefined dir... search online about the original file but can't find any.

#!/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
yup... heroku, but it now clashed. =( - shoujo_sm

1 Answers

0
votes

Try replacing dir with Rails.root (replace both occurrences). The variable or method dir was never defined in the above code. You could also define dir above daemon_options:

dir = Rails.root
daemon_options = {
  ...