AppController/djinn.rb
# Sends information about the AppServer processes hosting App Engine apps on
# this machine to the AppDashboard, for later viewing.
Sends information about the AppServer processes hosting App Engine apps on
this machine to the AppDashboard, for later viewing.
Sends information about the AppServer processes hosting App Engine apps on this machine to the AppDashboard for later viewing .
def send_instance_info_to_dashboard()
    APPS_LOCK.synchronize {
      instance_info = []
      @app_info_map.each_pair { |appid, app_info|
        next if app_info['appengine'].nil?
        app_info['appengine'].each { |location|
          host, port = location.split(":")
          next if Integer(port) < 0
          instance_info << {
            'appid' => appid,
            'host' => host,
            'port' => Integer(port),
            'language' => app_info['language']
          }
        }
      }
      begin
        url = URI.parse("https://#{get_load_balancer_ip()}:" +
          "#{AppDashboard::LISTEN_SSL_PORT}/apps/stats/instances")
        http = Net::HTTP.new(url.host, url.port)
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        response = http.post(url.path, JSON.dump(instance_info),
          {'Content-Type'=>'application/json'})
        Djinn.log_debug("Done sending instance info to AppDashboard. Info is: " +
          "#{instance_info.inspect}. Response is: #{response.body}.")
      rescue OpenSSL::SSL::SSLError, NotImplementedError, Errno::EPIPE,
        Errno::ECONNRESET => e
        backtrace = e.backtrace.join("\n")
        Djinn.log_warn("Error in send_instance_info: #{e.message}\n#{backtrace}")
        retry
      rescue => exception
        Djinn.log_warn("Couldn't send instance info to the AppDashboard " +
          "because of a #{exception.class} exception.")
      end
    }
  end
def send_instance_info_to_dashboard ( ) APPS_LOCK . synchronize { instance_info = [ ] @app_info_map . each_pair { | appid , app_info | next if app_info [ 'appengine' ] . nil? app_info [ 'appengine' ] . each { | location | host , port = location . split ( ":" ) next if Integer ( port ) < 0 instance_info << { 'appid' => appid , 'host' => host , 'port' => Integer ( port ) , 'language' => app_info [ 'language' ] } } } begin url = URI . parse ( "https://#{get_load_balancer_ip()}:" + "#{AppDashboard::LISTEN_SSL_PORT}/apps/stats/instances" ) http = Net :: HTTP . new ( url . host , url . port ) http . use_ssl = true http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE response = http . post ( url . path , JSON . dump ( instance_info ) , { 'Content-Type' => 'application/json' } ) Djinn . log_debug ( "Done sending instance info to AppDashboard. Info is: " + "#{instance_info.inspect}. Response is: #{response.body}." ) rescue OpenSSL :: SSL :: SSLError , NotImplementedError , Errno :: EPIPE , Errno :: ECONNRESET => e backtrace = e . backtrace . join ( "\n" ) Djinn . log_warn ( "Error in send_instance_info: #{e.message}\n#{backtrace}" ) retry rescue => exception Djinn . log_warn ( "Couldn't send instance info to the AppDashboard " + "because of a #{exception.class} exception." ) end } end
Sends information about the AppServer processes hosting App Engine apps on
this machine to the AppDashboard, for later viewing.
Sends information about the AppServer processes hosting App Engine apps on this machine to the AppDashboard for later viewing .
# Don't crash the AppController because we weren't able to send over # the instance info - just continue on.