Topic: How to run script with Daemons
In Rails 3.2.3 I have a delayed_delta script
#!/usr/bin/env ruby
#automatically called
#this is the current path where this is run in
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'), #this puts the pid files in /rails_path/tmp/pids
:backtrace => true
}
#this runs the first delayed job process
Daemons.run_proc('delayed_job_1', 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(
:min_priority => ENV['MIN_PRIORITY'],
:max_priority => ENV['MAX_PRIORITY']
).start
endAnd when I run
bundle exec script/delayed_delta stopI get
script/delayed_delta:19:in `<main>': uninitialized constant Daemons (NameError)But daemons is indeed in my Gemfile
gem 'daemons', '1.1.8' # latestThis worked previously on 2.3.14 before the upgrade.