public this repo is viewable by everyone
Description: Database based asynchronously priority queue system -- Extracted from Shopify
Homepage: http://www.shopify.com
Clone URL: git://github.com/tobi/delayed_job.git
Small corrections for the included rake task
Tobias Lütke (author)
about 1 month ago
commit  3e4e1acec1c19623d93fa75bdbcdf74ae89afb41
tree    0e7268e8354097fc46260ae933a655dd0d234694
parent  8ec934eef96cd5622713eb7c621441cbafabe55d
...
1
 
2
3
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
 
 
 
 
 
 
18
19
 
20
21
 
22
23
 
 
 
24
25
26
 
 
27
28
29
30
...
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
 
 
 
 
 
13
14
15
16
17
18
19
20
21
22
 
23
24
25
26
27
 
28
29
30
31
 
 
32
33
34
35
36
37
0
@@ -1,29 +1,36 @@
0
 namespace :jobs do
0
+
0
                
0
   task :work => :environment do
0
+
0
+ puts "*** Staring job worker #{Delayed::Job.worker_name}"
0
     
0
     SLEEP = 5
0
      
0
     trap('TERM') { puts 'Exiting...'; $exit = true }
0
     trap('INT') { puts 'Exiting...'; $exit = true }
0
 
0
- loop do
0
-
0
- count = 0
0
-
0
- realtime = Benchmark.realtime do
0
- count = Delayed::Job.work_off
0
- end
0
-
0
+ loop do
0
+ result = nil
0
+
0
+ realtime = Benchmark.realtime do
0
+ result = Delayed::Job.work_off
0
+ end
0
+
0
+ count = result.sum
0
+
0
       break if $exit
0
-
0
+
0
       if count.zero?
0
         sleep(SLEEP)
0
+ puts 'Waiting for more jobs...'
0
       else
0
- RAILS_DEFAULT_LOGGER.info "#{count} jobs completed at %.2f j/s ..." % [count / realtime]
0
+ status = "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
0
+ RAILS_DEFAULT_LOGGER.info status
0
+ puts status
0
       end
0
-
0
- break if $exit
0
+
0
+ break if $exit
0
     end
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.