AppController/djinn.rb
# Starts a new AppServer for the given application.
#
# Args:
#   app: A String naming the application that an additional instance will
#     be added for.
#   nginx_port: A String or Fixnum that names the port that should be used to
#     serve HTTP traffic for this app.
#   https_port: A String or Fixnum that names the port that should be used to
#     serve HTTPS traffic for this app.
#   app_language: A String naming the language of the application.
# Returns:
#   A Boolean to indicate if the AppServer was successfully started.
Starts a new AppServer for the given application.
Args:
app: A String naming the application that an additional instance will
be added for.
nginx_port: A String or Fixnum that names the port that should be used to
serve HTTP traffic for this app.
https_port: A String or Fixnum that names the port that should be used to
serve HTTPS traffic for this app.
app_language: A String naming the language of the application.
Returns:
A Boolean to indicate if the AppServer was successfully started.
Starts a new AppServer for the given application . Args : app : A String naming the application that an additional instance will be added for . nginx_port : A String or Fixnum that names the port that should be used to serve HTTP traffic for this app . https_port : A String or Fixnum that names the port that should be used to serve HTTPS traffic for this app . app_language : A String naming the language of the application . Returns : A Boolean to indicate if the AppServer was successfully started .
def add_appserver_process(app, nginx_port, https_port, app_language)
    Djinn.log_info("Received request to add an AppServer for #{app}.")
    setup_app_dir(app)
    port_file = "#{APPSCALE_CONFIG_DIR}/port-#{app}.txt"
    unless File.exists?(port_file)
      Djinn.log_info("Waiting for port file for app #{app}.")
      return false
    end
    appengine_port = find_lowest_free_port(STARTING_APPENGINE_PORT)
    if appengine_port < 0
      Djinn.log_error("Failed to get port for application #{app} on " +
        "#{@my_private_ip}")
      return false
    end
    Djinn.log_info("Starting #{app_language} app #{app} on " +
      "#{@my_private_ip}:#{appengine_port}")
    xmpp_ip = get_login.public_ip
    app_manager = AppManagerClient.new(my_node.private_ip)
    begin
      pid = app_manager.start_app(app, appengine_port,
        get_load_balancer_ip(), app_language, xmpp_ip,
        HelperFunctions.get_app_env_vars(app),
        Integer(@options['max_memory']), get_login.private_ip)
    rescue FailedNodeException, AppScaleException, ArgumentError => error
      Djinn.log_warn("#{error.class} encountered while starting #{app} "\
        "with AppManager: #{error.message}")
      pid = -1
    end
    if pid < 0
      Djinn.log_warn("Something went wrong starting AppServer for" +
        " #{app}: check logs and running processes as duplicate" +
        " ports may have been allocated.")
    end
    maybe_start_taskqueue_worker(app)
    Djinn.log_info("Done adding AppServer for #{app}.")
    return true
  end
def add_appserver_process ( app , nginx_port , https_port , app_language ) Djinn . log_info ( "Received request to add an AppServer for #{app}." ) setup_app_dir ( app ) port_file = "#{APPSCALE_CONFIG_DIR}/port-#{app}.txt" unless File . exists? ( port_file ) Djinn . log_info ( "Waiting for port file for app #{app}." ) return false end appengine_port = find_lowest_free_port ( STARTING_APPENGINE_PORT ) if appengine_port < 0 Djinn . log_error ( "Failed to get port for application #{app} on " + "#{@my_private_ip}" ) return false end Djinn . log_info ( "Starting #{app_language} app #{app} on " + "#{@my_private_ip}:#{appengine_port}" ) xmpp_ip = get_login . public_ip app_manager = AppManagerClient . new ( my_node . private_ip ) begin pid = app_manager . start_app ( app , appengine_port , get_load_balancer_ip ( ) , app_language , xmpp_ip , HelperFunctions . get_app_env_vars ( app ) , Integer ( @options [ 'max_memory' ] ) , get_login . private_ip ) rescue FailedNodeException , AppScaleException , ArgumentError => error Djinn . log_warn ( "#{error.class} encountered while starting #{app} " "with AppManager: #{error.message}" ) pid = - 1 end if pid < 0 Djinn . log_warn ( "Something went wrong starting AppServer for" + " #{app}: check logs and running processes as duplicate" + " ports may have been allocated." ) end maybe_start_taskqueue_worker ( app ) Djinn . log_info ( "Done adding AppServer for #{app}." ) return true end
Starts a new AppServer for the given application.
Starts a new AppServer for the given application .
# Make sure we have the application setup properly. # Wait for the head node to be setup for this app. # TODO: What happens if the user updates their env vars between app # deploys? # Something may have gone wrong: inform the user and move on.
app
<not_specific>
nginx_port
<not_specific>
https_port
<not_specific>
app_language
<not_specific>