Module: VirtualMonkey::Frontend
- Included in:
- ApplicationFrontend
- Defined in:
- lib/virtualmonkey/frontend.rb
Instance Method Summary collapse
- #cross_connect_frontends ⇒ Object
-
#fe_servers ⇒ Object
returns an Array of the Front End servers in the deployment.
- #frontend_checks ⇒ Object
-
#get_lb_hostname_input ⇒ Object
returns String with all the private dns of the Front End servers used for setting the LB_HOSTNAME input.
- #lookup_scripts ⇒ Object
-
#run_fe_tests ⇒ Object
Run spot checks for FE servers in the deployment.
-
#startup ⇒ Object
Special startup sequence for an FE deployment.
Instance Method Details
#cross_connect_frontends ⇒ Object
91 92 93 94 95 96 |
# File 'lib/virtualmonkey/frontend.rb', line 91 def cross_connect_frontends statuses = Array.new = { :LB_HOSTNAME => behavior(:get_lb_hostname_input) } fe_servers.each { |s| statuses << object_behavior(s, :run_executable, @scripts_to_run['connect'], ) } statuses.each_with_index { |s,i| s.wait_for_completed } end |
#fe_servers ⇒ Object
returns an Array of the Front End servers in the deployment
7 8 9 10 11 |
# File 'lib/virtualmonkey/frontend.rb', line 7 def fe_servers res = @servers.select { |s| s.nickname =~ /Front End/ || s.nickname =~ /FrontEnd/ || s.nickname =~ /Apache with HAproxy/ || s.nickname =~ /Load Balancer/ } raise "FATAL: No frontend servers found" unless res.length > 0 res end |
#frontend_checks ⇒ Object
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/virtualmonkey/frontend.rb', line 34 def frontend_checks behavior(:detect_os) behavior(:run_unified_application_checks, fe_servers, 80) # check that all application servers exist in the haproxy config file on all fe_servers server_ips = Array.new app_servers.each { |app| server_ips << app['private-ip-address'] } fe_servers.each do |fe| fe.settings haproxy_config = object_behavior(fe, :spot_check_command, 'flock -n /home/haproxy/rightscale_lb.cfg -c "cat /home/haproxy/rightscale_lb.cfg | grep server"') puts "INFO: flock status was #{haproxy_config[:status]}" server_ips.each do |ip| if haproxy_config.to_s.include?(ip) == false puts haproxy_config[:output] raise "FATAL: haproxy config did not contain server ip #{ip}" end end end # restart haproxy and check that it succeeds fe_servers.each_with_index do |server,i| response = object_behavior(server, :spot_check_command?, 'service haproxy stop') raise "Haproxy stop command failed" unless response stopped = false count = 0 until response || count > 3 do response = object_behavior(server, :spot_check_command, server.haproxy_check) stopped = response.include?("not running") break if stopped count += 1 sleep 10 end response = object_behavior(server, :spot_check_command?, 'service haproxy start') raise "Haproxy start failed" unless response end # restart apache and check that it succeeds statuses = Array.new fe_servers.each { |s| statuses << object_behavior(s, :run_executable, @scripts_to_run['apache_restart']) } statuses.each { |status| status.wait_for_completed } fe_servers.each_with_index do |server,i| response = nil count = 0 until response || count > 3 do response = object_behavior(server, :spot_check_command?, server.apache_check) break if response count += 1 sleep 10 end raise "Apache status failed" unless response end end |
#get_lb_hostname_input ⇒ Object
returns String with all the private dns of the Front End servers used for setting the LB_HOSTNAME input.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/virtualmonkey/frontend.rb', line 15 def get_lb_hostname_input lb_hostname_input = "text:" fe_servers.each do |fe| timeout = 30 loopcounter = 0 begin if fe.settings['private-dns-name'] == nil raise "FATAL: private DNS name is empty" if loopcounter > 10 sleep(timeout) loopcounter += 1 next end lb_hostname_input << fe.settings['private-dns-name'] + " " done = true end while !done end lb_hostname_input end |
#lookup_scripts ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/virtualmonkey/frontend.rb', line 98 def lookup_scripts fe_scripts = [ [ 'apache_restart', 'WEB apache \(re\)start' ] ] app_scripts = [ [ 'connect', 'LB [app|mongrels]+ to HA proxy connect' ] ] # @scripts_to_run = {} st = ServerTemplate.find(fe_servers.first.server_template_href) lookup_scripts_table(st,fe_scripts) st = ServerTemplate.find(app_servers.first.server_template_href) lookup_scripts_table(st,app_scripts) # @scripts_to_run['connect'] = st.executables.detect { |ex| ex.name =~ /LB [app|mongrels]+ to HA proxy connect/i } # @scripts_to_run['apache_restart'] = st.executables.detect { |ex| ex.name =~ /WEB apache \(re\)start v2/i } end |
#run_fe_tests ⇒ Object
Run spot checks for FE servers in the deployment
116 117 |
# File 'lib/virtualmonkey/frontend.rb', line 116 def run_fe_tests end |
#startup ⇒ Object
Special startup sequence for an FE deployment
120 121 |
# File 'lib/virtualmonkey/frontend.rb', line 120 def startup end |