Class Rudy::Routines::Shutdown

  1. lib/rudy/routines/shutdown.rb

Methods

public instance

  1. execute
  2. init
  3. raise_early_exceptions

Public instance methods

execute ()

Startup routines run in the following order:

  • before dependencies
  • all other actions (except after_local)
  • Shutdown instances
  • after_local (if present)
  • after dependencies
[show source]
    # File lib/rudy/routines/shutdown.rb, line 25
25:     def execute
26:       
27:       # We need to remove after_local so the runner doesn't see it
28:       after_local = @routine.delete(:after_local)
29:       
30:       if run?
31:         Rudy::Routines.rescue {
32:           Rudy::Routines::Handlers::Group.authorize rescue nil
33:         }
34:         
35:         Rudy::Routines::Handlers::Depends.execute_all @before, @argv
36:         
37:         li " Executing routine: #{@name} ".att(:reverse), ""
38:         ld "[this is a generic routine]" if @routine.empty?
39:         
40:         # Re-retreive the machine set to reflect dependency changes
41:         Rudy::Routines.rescue {
42:           @machines = Rudy::Machines.list || []
43:           @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
44:         }
45:         
46:         # This is the meat of the sandwich
47:         Rudy::Routines.runner(@routine, @@rset, @@lbox, @argv)
48:         
49:         @machines.each do |machine|
50:           Rudy::Routines.rescue { machine.destroy }
51:         end
52:       
53:         if after_local
54:           handler = Rudy::Routines.get_handler :local
55:           Rudy::Routines.rescue {
56:             handler.execute(:local, after_local, nil, @@lbox, @argv)
57:           }
58:         end
59:       
60:         Rudy::Routines::Handlers::Depends.execute_all @after, @argv
61:       end
62:       
63:       @machines
64:     end
init (*args)
[show source]
    # File lib/rudy/routines/shutdown.rb, line 11
11:     def init(*args)
12:       @routine ||= {}
13:       Rudy::Routines.rescue {
14:         @machines = Rudy::Machines.list || []
15:         @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
16:       }
17:     end
raise_early_exceptions ()

Called by generic_machine_runner

[show source]
    # File lib/rudy/routines/shutdown.rb, line 67
67:     def raise_early_exceptions
68:       raise NoMachinesConfig unless @@config.machines
69:       
70:       # If this is a test run we don't care if the group is running
71:       if run?
72:         if @@global.position.nil?
73:           raise MachineGroupNotRunning, current_machine_group unless Rudy::Machines.running?
74:         else
75:           unless Rudy::Machines.running? @@global.position
76:             m = Rudy::Machine.new @@global.position
77:             raise MachineNotRunning, m.name 
78:           end
79:         end
80:       end
81:       
82:       ## NOTE: This check is disabled for now. If the private key doesn't exist
83:       ## it prevents shutting down.
84:       # Check private key after machine group, otherwise we could get an error
85:       # about there being no key which doesn't make sense if the group isn't running.
86:       ##raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(current_machine_root)
87:       if @routine
88:         bad = @routine.keys - @@allowed_actions
89:         raise UnsupportedActions.new(@name, bad) unless bad.empty?
90:       end
91:     end