cook 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +14 -0
  2. data/lib/cook.rb +1 -1
  3. data/lib/rake/config.rb +25 -9
  4. metadata +2 -2
@@ -1,3 +1,17 @@
1
+ === 2.0.9 / 2014-09-16 (external GitHub)
2
+
3
+ * Added Conf.retries to allow gl_run (GreenLetters based) processes
4
+ which throw an exception to be retried a number of times.
5
+
6
+ * This allows processes conducted over noisy internet connections to
7
+ be automatically retried a number of times.
8
+
9
+ * Each failed attempt is log if tracing is enabled
10
+
11
+ * The current default retry number is 5. This can be overridden by
12
+ either Conf.retries (globally) or options[:retries] (locally for a
13
+ given gl_run call).
14
+
1
15
  === 2.0.1 / 2014-01-15 (external GitHub)
2
16
 
3
17
  * 2.0.1 minor testing
@@ -1,3 +1,3 @@
1
1
  class Cook
2
- VERSION = '2.0.8'
2
+ VERSION = '2.0.9'
3
3
  end
@@ -666,10 +666,13 @@ module Rake
666
666
  else
667
667
  options[:timeout] = 10;
668
668
  end
669
+ Conf.retries = 5 unless Conf.has_key?(:retries)
670
+ options[:retries] = Conf.retries unless options.has_key?(:retries)
669
671
 
670
672
  Rake::Application.mesg args.join(' ') if $TRACE
671
673
  Rake::Application.mesg "Timeout: #{options[:timeout]}" if $TRACE
672
674
  Rake::Application.mesg "#{options}" if $TRACE && !options.empty?() && options.has_key?(:verbose);
675
+ Rake::Application.mesg "Retries: #{options[:retries]}" if $TRACE
673
676
 
674
677
  asyncTriggersBlocks = Array.new;
675
678
  if options.has_key? :asyncTriggersBlocks then
@@ -684,19 +687,32 @@ module Rake
684
687
  options[:env] = ENV unless options.has_key?(:env);
685
688
  options[:transcript] = Rake::Application.logger unless options.has_key?(:transcript);
686
689
 
687
- cmdProcess = Greenletters::Process.new(*args, options);
688
- cmdProcess.start!;
690
+ attempt = 0
691
+ tryAgain = true
692
+ cmdProcess = nil
693
+ while(tryAgain) do
694
+ attempt += 1
695
+ tryAgain = false
696
+ begin
697
+ cmdProcess = Greenletters::Process.new(*args, options);
698
+ cmdProcess.start!;
699
+
700
+ asyncTriggersBlocks.each do | asyncTriggersBlock |
701
+ if asyncTriggersBlock.kind_of? Proc then
702
+ asyncTriggersBlock.call(cmdProcess);
703
+ end
704
+ end
705
+
706
+ aBlock.call(cmdProcess) unless aBlock.nil?;
689
707
 
690
- asyncTriggersBlocks.each do | asyncTriggersBlock |
691
- if asyncTriggersBlock.kind_of? Proc then
692
- asyncTriggersBlock.call(cmdProcess);
708
+ cmdProcess.wait_for(:exit, exitStatus);
709
+ rescue StandardError => se
710
+ Rake::Application.mesg "Failed attempt #{attempt}" if $TRACE
711
+ tryAgain = true
712
+ raise se unless attempt < options[:retries]
693
713
  end
694
714
  end
695
715
 
696
- aBlock.call(cmdProcess) unless aBlock.nil?;
697
-
698
- cmdProcess.wait_for(:exit, exitStatus);
699
-
700
716
  cmdProcess
701
717
  end
702
718
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cook
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-22 00:00:00.000000000 Z
12
+ date: 2014-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake