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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/vector/cli.rb', line 13
def run
load_config
auto_scaling = AWS::AutoScaling.new(:region => @config[:region])
cloudwatch = AWS::CloudWatch.new(:region => @config[:region])
AWS.start_memoizing
groups = if @config[:fleet]
auto_scaling.fleets[@config[:fleet]].groups
else
@config[:groups].map do |group_name|
auto_scaling.groups[group_name]
end
end
ps = nil
if @config[:predictive_scaling][:enabled]
psconf = @config[:predictive_scaling]
ps = Vector::Function::PredictiveScaling.new(
{ :cloudwatch => cloudwatch }.merge(psconf))
end
fds = nil
if @config[:flexible_down_scaling][:enabled]
fdsconf = @config[:flexible_down_scaling]
fds = Vector::Function::FlexibleDownScaling.new(
{ :cloudwatch => cloudwatch }.merge(fdsconf))
end
groups.each do |group|
begin
ps_check_procs = nil
if ps
ps_result = ps.run_for(group)
ps_check_procs = ps_result[:check_procs]
if ps_result[:triggered]
next
end
end
if fds
fds.run_for(group, ps_check_procs)
end
rescue => e
puts "error for #{group.name}: #{e.inspect}\n#{e.backtrace.join "\n"}"
end
end
end
|