Permalink
Browse files

Small corrections for the included rake task

  • Loading branch information...
1 parent 8ec934e commit 3e4e1acec1c19623d93fa75bdbcdf74ae89afb41 @tobi committed Mar 23, 2008
Showing with 19 additions and 12 deletions.
  1. +19 −12 tasks/jobs.rake
View
@@ -1,29 +1,36 @@
namespace :jobs do
+
task :work => :environment do
+
+ puts "*** Staring job worker #{Delayed::Job.worker_name}"
SLEEP = 5
trap('TERM') { puts 'Exiting...'; $exit = true }
trap('INT') { puts 'Exiting...'; $exit = true }
- loop do
-
- count = 0
-
- realtime = Benchmark.realtime do
- count = Delayed::Job.work_off
- end
-
+ loop do
+ result = nil
+
+ realtime = Benchmark.realtime do
+ result = Delayed::Job.work_off
+ end
+
+ count = result.sum
+
break if $exit
-
+
if count.zero?
sleep(SLEEP)
+ puts 'Waiting for more jobs...'
else
- RAILS_DEFAULT_LOGGER.info "#{count} jobs completed at %.2f j/s ..." % [count / realtime]
+ status = "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
+ RAILS_DEFAULT_LOGGER.info status
+ puts status
end
-
- break if $exit
+
+ break if $exit
end
end
end

0 comments on commit 3e4e1ac

Please sign in to comment.