right_agent 0.10.9 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/right_agent/agent.rb +17 -9
 - data/right_agent.gemspec +3 -3
 - data/spec/agent_spec.rb +1 -1
 - metadata +12 -5
 
    
        data/lib/right_agent/agent.rb
    CHANGED
    
    | 
         @@ -222,7 +222,13 @@ module RightScale 
     | 
|
| 
       222 
222 
     | 
    
         
             
                          end
         
     | 
| 
       223 
223 
     | 
    
         
             
                        end
         
     | 
| 
       224 
224 
     | 
    
         
             
                      elsif status == :failed
         
     | 
| 
       225 
     | 
    
         
            -
                        Log.error("Agent failed to connect to any brokers")
         
     | 
| 
      
 225 
     | 
    
         
            +
                        Log.error("Agent failed to connect to any brokers during startup")
         
     | 
| 
      
 226 
     | 
    
         
            +
                        EM.stop
         
     | 
| 
      
 227 
     | 
    
         
            +
                      elsif status == :timeout
         
     | 
| 
      
 228 
     | 
    
         
            +
                        Log.error("Agent failed to connect to any brokers after #{@options[:connect_timeout]} seconds during startup")
         
     | 
| 
      
 229 
     | 
    
         
            +
                        EM.stop
         
     | 
| 
      
 230 
     | 
    
         
            +
                      else
         
     | 
| 
      
 231 
     | 
    
         
            +
                        Log.error("Agent broker connect attempt failed unexpectedly with status #{status} during startup")
         
     | 
| 
       226 
232 
     | 
    
         
             
                        EM.stop
         
     | 
| 
       227 
233 
     | 
    
         
             
                      end
         
     | 
| 
       228 
234 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -465,14 +471,14 @@ module RightScale 
     | 
|
| 
       465 
471 
     | 
    
         
             
                #
         
     | 
| 
       466 
472 
     | 
    
         
             
                # === Return
         
     | 
| 
       467 
473 
     | 
    
         
             
                # true:: Always return true
         
     | 
| 
       468 
     | 
    
         
            -
                def terminate(& 
     | 
| 
      
 474 
     | 
    
         
            +
                def terminate(&block)
         
     | 
| 
       469 
475 
     | 
    
         
             
                  begin
         
     | 
| 
       470 
476 
     | 
    
         
             
                    if @terminating
         
     | 
| 
       471 
477 
     | 
    
         
             
                      Log.info("[stop] Terminating immediately")
         
     | 
| 
       472 
478 
     | 
    
         
             
                      @termination_timer.cancel if @termination_timer
         
     | 
| 
       473 
479 
     | 
    
         
             
                      @termination_timer = nil
         
     | 
| 
       474 
     | 
    
         
            -
                       
     | 
| 
       475 
     | 
    
         
            -
                      EM.stop
         
     | 
| 
      
 480 
     | 
    
         
            +
                      block.call if block
         
     | 
| 
      
 481 
     | 
    
         
            +
                      EM.stop if EM.reactor_running?
         
     | 
| 
       476 
482 
     | 
    
         
             
                    else
         
     | 
| 
       477 
483 
     | 
    
         
             
                      @terminating = true
         
     | 
| 
       478 
484 
     | 
    
         
             
                      @check_status_timer.cancel if @check_status_timer
         
     | 
| 
         @@ -489,8 +495,7 @@ module RightScale 
     | 
|
| 
       489 
495 
     | 
    
         
             
                            request_count, request_age = @sender.terminate
         
     | 
| 
       490 
496 
     | 
    
         
             
                            Log.info("[stop] The following #{request_count} requests initiated as recently as #{request_age} " +
         
     | 
| 
       491 
497 
     | 
    
         
             
                                     "seconds ago are being dropped:\n  " + @sender.dump_requests.join("\n  ")) if request_age
         
     | 
| 
       492 
     | 
    
         
            -
                            @broker.close {  
     | 
| 
       493 
     | 
    
         
            -
                            EM.stop unless blk
         
     | 
| 
      
 498 
     | 
    
         
            +
                            @broker.close { block.call if block; EM.stop if EM.reactor_running? }
         
     | 
| 
       494 
499 
     | 
    
         
             
                          end
         
     | 
| 
       495 
500 
     | 
    
         | 
| 
       496 
501 
     | 
    
         
             
                          wait_time = [timeout - (request_age || timeout), timeout - (dispatch_age || timeout), 0].max
         
     | 
| 
         @@ -508,16 +513,19 @@ module RightScale 
     | 
|
| 
       508 
513 
     | 
    
         
             
                                finish.call
         
     | 
| 
       509 
514 
     | 
    
         
             
                              rescue Exception => e
         
     | 
| 
       510 
515 
     | 
    
         
             
                                Log.error("Failed while finishing termination", e, :trace)
         
     | 
| 
       511 
     | 
    
         
            -
                                EM.stop
         
     | 
| 
      
 516 
     | 
    
         
            +
                                EM.stop if EM.reactor_running?
         
     | 
| 
       512 
517 
     | 
    
         
             
                              end
         
     | 
| 
       513 
518 
     | 
    
         
             
                            end
         
     | 
| 
       514 
519 
     | 
    
         
             
                          end
         
     | 
| 
      
 520 
     | 
    
         
            +
                        else
         
     | 
| 
      
 521 
     | 
    
         
            +
                          block.call if block
         
     | 
| 
      
 522 
     | 
    
         
            +
                          EM.stop if EM.reactor_running?
         
     | 
| 
       515 
523 
     | 
    
         
             
                        end
         
     | 
| 
       516 
524 
     | 
    
         
             
                      end
         
     | 
| 
       517 
525 
     | 
    
         
             
                    end
         
     | 
| 
       518 
526 
     | 
    
         
             
                  rescue Exception => e
         
     | 
| 
       519 
527 
     | 
    
         
             
                    Log.error("Failed to terminate gracefully", e, :trace)
         
     | 
| 
       520 
     | 
    
         
            -
                    EM.stop
         
     | 
| 
      
 528 
     | 
    
         
            +
                    EM.stop if EM.reactor_running?
         
     | 
| 
       521 
529 
     | 
    
         
             
                  end
         
     | 
| 
       522 
530 
     | 
    
         
             
                  true
         
     | 
| 
       523 
531 
     | 
    
         
             
                end
         
     | 
| 
         @@ -729,7 +737,7 @@ module RightScale 
     | 
|
| 
       729 
737 
     | 
    
         
             
                      EM.next_tick do
         
     | 
| 
       730 
738 
     | 
    
         
             
                        begin
         
     | 
| 
       731 
739 
     | 
    
         
             
                          terminate do
         
     | 
| 
       732 
     | 
    
         
            -
                            EM.stop
         
     | 
| 
      
 740 
     | 
    
         
            +
                            EM.stop if EM.reactor_running?
         
     | 
| 
       733 
741 
     | 
    
         
             
                            old.call if old.is_a? Proc
         
     | 
| 
       734 
742 
     | 
    
         
             
                          end
         
     | 
| 
       735 
743 
     | 
    
         
             
                        rescue Exception => e
         
     | 
    
        data/right_agent.gemspec
    CHANGED
    
    | 
         @@ -24,8 +24,8 @@ require 'rubygems' 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       26 
26 
     | 
    
         
             
              spec.name      = 'right_agent'
         
     | 
| 
       27 
     | 
    
         
            -
              spec.version   = '0.10. 
     | 
| 
       28 
     | 
    
         
            -
              spec.date      = '2012-06- 
     | 
| 
      
 27 
     | 
    
         
            +
              spec.version   = '0.10.10'
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.date      = '2012-06-25'
         
     | 
| 
       29 
29 
     | 
    
         
             
              spec.authors   = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro']
         
     | 
| 
       30 
30 
     | 
    
         
             
              spec.email     = 'lee@rightscale.com'
         
     | 
| 
       31 
31 
     | 
    
         
             
              spec.homepage  = 'https://github.com/rightscale/right_agent'
         
     | 
| 
         @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       37 
37 
     | 
    
         
             
              spec.required_ruby_version = '>= 1.8.7'
         
     | 
| 
       38 
38 
     | 
    
         
             
              spec.require_path = 'lib'
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
              spec.add_dependency('right_support', ' 
     | 
| 
      
 40 
     | 
    
         
            +
              spec.add_dependency('right_support', ['>= 1.3', '< 3.0'])
         
     | 
| 
       41 
41 
     | 
    
         
             
              spec.add_dependency('right_amqp', '~> 0.3')
         
     | 
| 
       42 
42 
     | 
    
         
             
              spec.add_dependency('json', ['~> 1.4'])
         
     | 
| 
       43 
43 
     | 
    
         
             
              spec.add_dependency('eventmachine', '~> 0.12.10')
         
     | 
    
        data/spec/agent_spec.rb
    CHANGED
    
    | 
         @@ -684,7 +684,7 @@ describe RightScale::Agent do 
     | 
|
| 
       684 
684 
     | 
    
         
             
                    @sender.should_receive(:terminate).and_return([1, 10]).twice
         
     | 
| 
       685 
685 
     | 
    
         
             
                    @sender.should_receive(:dump_requests).and_return(["request"]).once
         
     | 
| 
       686 
686 
     | 
    
         
             
                    @dispatcher.should_receive(:dispatch_age).and_return(10).once
         
     | 
| 
       687 
     | 
    
         
            -
                    @broker.should_receive(:close).once
         
     | 
| 
      
 687 
     | 
    
         
            +
                    @broker.should_receive(:close).and_yield.once
         
     | 
| 
       688 
688 
     | 
    
         
             
                    flexmock(EM::Timer).should_receive(:new).with(20, Proc).and_return(@timer).and_yield.once
         
     | 
| 
       689 
689 
     | 
    
         
             
                    run_in_em(stop_event_loop = false) do
         
     | 
| 
       690 
690 
     | 
    
         
             
                      @agent = RightScale::Agent.new(:user => "me", :identity => @identity)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: right_agent
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 35
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 10
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.10. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 10
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.10.10
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Lee Kirchhoff
         
     | 
| 
         @@ -17,20 +17,27 @@ autorequire: 
     | 
|
| 
       17 
17 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       18 
18 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            date: 2012-06- 
     | 
| 
      
 20 
     | 
    
         
            +
            date: 2012-06-25 00:00:00 -07:00
         
     | 
| 
       21 
21 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       22 
22 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       23 
23 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       24 
24 
     | 
    
         
             
              version_requirements: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
       25 
25 
     | 
    
         
             
                none: false
         
     | 
| 
       26 
26 
     | 
    
         
             
                requirements: 
         
     | 
| 
       27 
     | 
    
         
            -
                - -  
     | 
| 
      
 27 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       28 
28 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       29 
29 
     | 
    
         
             
                    hash: 9
         
     | 
| 
       30 
30 
     | 
    
         
             
                    segments: 
         
     | 
| 
       31 
31 
     | 
    
         
             
                    - 1
         
     | 
| 
       32 
32 
     | 
    
         
             
                    - 3
         
     | 
| 
       33 
33 
     | 
    
         
             
                    version: "1.3"
         
     | 
| 
      
 34 
     | 
    
         
            +
                - - <
         
     | 
| 
      
 35 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 36 
     | 
    
         
            +
                    hash: 7
         
     | 
| 
      
 37 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 38 
     | 
    
         
            +
                    - 3
         
     | 
| 
      
 39 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: "3.0"
         
     | 
| 
       34 
41 
     | 
    
         
             
              requirement: *id001
         
     | 
| 
       35 
42 
     | 
    
         
             
              name: right_support
         
     | 
| 
       36 
43 
     | 
    
         
             
              prerelease: false
         
     |