stager/lib/vcap/stager/task.rb
# Stages the application into the supplied directory.
Stages the application into the supplied directory.
Stages the application into the supplied directory .
def stage_app(src_dir, dst_dir, task_logger)
    plugin_config = {
      "source_dir"   => src_dir,
      "dest_dir"     => dst_dir,
      "environment"  => @request["properties"],
      "manifest_dir" => @manifest_dir,
    }
    secure_user = nil
    if @user_manager
      secure_user = @user_manager.checkout_user
      plugin_config["secure_user"] = {
        "uid" => secure_user[:uid],
        "gid" => secure_user[:gid],
      }
    end
    plugin_config_file = Tempfile.new("plugin_config")
    StagingPlugin::Config.to_file(plugin_config, plugin_config_file.path)
    cmd = [@ruby_path, @run_plugin_path,
           @request["properties"]["framework"],
           plugin_config_file.path].join(" ")
    res = @runner.run_logged(cmd,
                             :max_staging_duration => @max_staging_duration)
    capture_staging_log(dst_dir, task_logger)
    unless res[:status].success?
      emsg = nil
      if res[:timed_out]
        emsg = "Staging timed out after #{@max_staging_duration} seconds."
      else
        emsg = "Staging plugin failed: #{res[:stderr]}"
      end
      task_logger.warn(emsg)
      raise VCAP::Stager::TaskError.new(emsg)
    end
    nil
  ensure
    plugin_config_file.unlink if plugin_config_file
    return_secure_user(secure_user) if secure_user
  end
def stage_app ( src_dir , dst_dir , task_logger ) plugin_config = { "source_dir" => src_dir , "dest_dir" => dst_dir , "environment" => @request [ "properties" ] , "manifest_dir" => @manifest_dir , } secure_user = nil if @user_manager secure_user = @user_manager . checkout_user plugin_config [ "secure_user" ] = { "uid" => secure_user [ :uid ] , "gid" => secure_user [ :gid ] , } end plugin_config_file = Tempfile . new ( "plugin_config" ) StagingPlugin :: Config . to_file ( plugin_config , plugin_config_file . path ) cmd = [ @ruby_path , @run_plugin_path , @request [ "properties" ] [ "framework" ] , plugin_config_file . path ] . join ( " " ) res = @runner . run_logged ( cmd , :max_staging_duration => @max_staging_duration ) capture_staging_log ( dst_dir , task_logger ) unless res [ :status ] . success? emsg = nil if res [ :timed_out ] emsg = "Staging timed out after #{@max_staging_duration} seconds." else emsg = "Staging plugin failed: #{res[:stderr]}" end task_logger . warn ( emsg ) raise VCAP :: Stager :: TaskError . new ( emsg ) end nil ensure plugin_config_file . unlink if plugin_config_file return_secure_user ( secure_user ) if secure_user end
Stages the application into the supplied directory.
Stages the application into the supplied directory .
# Staging failed, log the error and abort
src_dir
dst_dir
task_logger