lib/tasks.rb in zfben_rails_jobs-0.0.6 vs lib/tasks.rb in zfben_rails_jobs-0.0.7

- old
+ new

@@ -4,22 +4,21 @@ if defined? Rails jobs_root = Rails.root.join('tmp/jobs').to_s else jobs_root = File.realpath('.') << '/tmp/jobs' end - - desc 'Init Jobs Folders' - task :init do - FileUtils.mkdir(jobs_root) unless File.exists? jobs_root - end desc 'Start Jobs' task :start do system 'rake jobs:run >> log/jobs.log&' end desc 'Run Jobs' - task :run => [:init, :environment] do + task :run do + if defined? Rails + Rake::Task[:environment].execute + end + FileUtils.mkdir(jobs_root) unless File.exists? jobs_root File.open(jobs_root + '/.lock', 'w'){ |f| f.write Process.pid.to_s } print "Starting jobs at process##{Process.pid}\n" loop do list = Dir.glob(jobs_root + '/[a-z0-9-]*') if list.length > 0