AppController/djinn.rb
# Removes an application and stops all AppServers hosting this application.
#
# Args:
#   app_name: The application to stop
#   secret: Shared key for authentication
#
Removes an application and stops all AppServers hosting this application.
Args:
app_name: The application to stop
secret: Shared key for authentication
Removes an application and stops all AppServers hosting this application . Args : app_name : The application to stop secret : Shared key for authentication
def stop_app(app_name, secret)
    return BAD_SECRET_MSG unless valid_secret?(secret)
    unless my_node.is_shadow?
      Djinn.log_debug("Sending stop_app call for #{app_name} to shadow.")
      acc = AppControllerClient.new(get_shadow.private_ip, @@secret)
      begin
        return acc.stop_app(app_name)
      rescue FailedNodeException => except
        Djinn.log_warn("Failed to forward stop_app call to shadow (#{get_shadow}).")
        return NOT_READY
      end
    end
    app_name.gsub!(/[^\w\d\-]/, "")
    return "false: #{app_name} is a reserved app." if RESERVED_APPS.include?(app_name)
    Djinn.log_info("Shutting down app named [#{app_name}]")
    result = ""
    Thread.new {
      begin
        uac = UserAppClient.new(my_node.private_ip, @@secret)
        if not uac.does_app_exist?(app_name)
          Djinn.log_info("(stop_app) #{app_name} does not exist.")
        else
          result = uac.delete_app(app_name)
          Djinn.log_debug("(stop_app) delete_app returned: #{result}.")
        end
      rescue FailedNodeException
        Djinn.log_warn("(stop_app) delete_app: failed to talk " +
          "to the UserAppServer.")
      end
      APPS_LOCK.synchronize {
        @app_info_map.delete(app_name) unless @app_info_map[app_name].nil?
        @apps_loaded = @apps_loaded - [app_name]
        @app_names = @app_names - [app_name]
        @apps_loaded << "none" if @apps_loaded.empty?
        @app_names << "none" if @app_names.empty?
      }
      FileUtils.rm_rf("#{HelperFunctions.get_app_path(app_name)}")
      FileUtils.rm_rf("#{PERSISTENT_MOUNT_POINT}/apps/#{app_name}.tar.gz")
      CronHelper.clear_app_crontab(app_name)
    }
    return "true"
  end
def stop_app ( app_name , secret ) return BAD_SECRET_MSG unless valid_secret? ( secret ) unless my_node . is_shadow? Djinn . log_debug ( "Sending stop_app call for #{app_name} to shadow." ) acc = AppControllerClient . new ( get_shadow . private_ip , @@secret ) begin return acc . stop_app ( app_name ) rescue FailedNodeException => except Djinn . log_warn ( "Failed to forward stop_app call to shadow (#{get_shadow})." ) return NOT_READY end end app_name . gsub! ( / [^ \w \d \- ] / , "" ) return "false: #{app_name} is a reserved app." if RESERVED_APPS . include? ( app_name ) Djinn . log_info ( "Shutting down app named [#{app_name}]" ) result = "" Thread . new { begin uac = UserAppClient . new ( my_node . private_ip , @@secret ) if not uac . does_app_exist? ( app_name ) Djinn . log_info ( "(stop_app) #{app_name} does not exist." ) else result = uac . delete_app ( app_name ) Djinn . log_debug ( "(stop_app) delete_app returned: #{result}." ) end rescue FailedNodeException Djinn . log_warn ( "(stop_app) delete_app: failed to talk " + "to the UserAppServer." ) end APPS_LOCK . synchronize { @app_info_map . delete ( app_name ) unless @app_info_map [ app_name ] . nil? @apps_loaded = @apps_loaded - [ app_name ] @app_names = @app_names - [ app_name ] @apps_loaded << "none" if @apps_loaded . empty? @app_names << "none" if @app_names . empty? } FileUtils . rm_rf ( "#{HelperFunctions.get_app_path(app_name)}" ) FileUtils . rm_rf ( "#{PERSISTENT_MOUNT_POINT}/apps/#{app_name}.tar.gz" ) CronHelper . clear_app_crontab ( app_name ) } return "true" end
Removes an application and stops all AppServers hosting this application.
Removes an application and stops all AppServers hosting this application .
# Since stopping an application can take some time, we do it in a # thread. # If this node has any information about AppServers for this app, # clear that information out. # Prevent future deploys from using the old application code.
app_name
<not_specific>
secret
<not_specific>