Class: LaunchPad::Haproxy
Instance Attribute Summary
Attributes inherited from Command
#options
Instance Method Summary
collapse
Methods inherited from Command
#initialize, #invalidates_config?
Instance Method Details
#activate(options = {}) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/launch-pad/command/haproxy.rb', line 6
def activate(options = {})
begin
CreateNodes.migrate(:up)
rescue ActiveRecord::StatementInvalid => e
puts "Migration failed: #{e}"
end
end
|
#rebuild_config(options = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/launch-pad/command/haproxy.rb', line 18
def rebuild_config(options = {})
location = options[:with_templates]
to = options[:to]
puts "Rebuilding Haproxy config with: #{location}"
template = ERB.new File.read("#{location}/haproxy.erb")
result = template.result(binding)
File.open("#{to}/haproxy.conf", 'w') do |f|
f.write result
end
puts "Config file saved - restarting haproxy"
`killall haproxy`
`haproxy -f #{to}/haproxy.conf`
end
|
#servers_for(role, options = {}) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/launch-pad/command/haproxy.rb', line 32
def servers_for(role, options = {})
response = ""
Node.all.each_with_index do |node,index|
response = response + "server #{role}_#{options[:type]}_#{index} #{node.name} cookie app1inst1 check inter 2000 rise 2 fall 5\n"
end
response
end
|
#sets_activity? ⇒ Boolean
14
15
16
|
# File 'lib/launch-pad/command/haproxy.rb', line 14
def sets_activity?
true
end
|