How to solve delayed_job running problem in server machine?

If there is problem of running delayed job in your server machine then install “daemon-spawn” plugin and change the delayedjob script file as following…………..

require 'rubygems'

require 'daemon-spawn'

RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
Dir.chdir RAILS_ROOT
require File.join('config', 'environment')
Delayed::Worker.new.start
end
def stop
system("kill `cat #{RAILS_ROOT}/tmp/pids/delayed_job.pid`")
end
end
DelayedJobWorker.spawn!(:log_file => File.join(RAILS_ROOT, "log", "delayed_job.log"),
:pid_file => File.join(RAILS_ROOT, 'tmp', 'pids', 'delayed_job.pid'),
:sync_log => true,
:working_dir => RAILS_ROOT)

The RAKE task for this is bellow……………………………………….


desc "Start delayed_job process"

task :start_job, :roles => :app do

run "cd #{current_path}; chmod 755 script/delayed_job; RAILS_ENV=#{env} script/delayed_job start"

end

desc "Stop delayed_job process"

task :stop_job, :roles => :app do

run "cd #{current_path}; chmod 755 script/delayed_job; RAILS_ENV=#{env} script/delayed_job stop"

end
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: