Skip to content
Browse files

Do not capture buildpack output to log, allow streaming

Change-Id: Iee3549af23945bdc2d3f6237a61e54dbf7bd4016
  • Loading branch information...
1 parent ceb0685 commit 9d40f3ff983cb6b4b2eb839afce0e2eb18aff6ec Jennifer Hickey and Nate Clark committed Feb 1, 2013
View
8 lib/vcap/staging/plugin/buildpack/buildpack_installer.rb
@@ -1,13 +1,9 @@
require "open3"
-require "vcap/staging/plugin/shell_helpers"
class BuildpackInstaller < Struct.new(:path, :app_dir, :logger)
- include ShellHelpers
def detect
- logger.info "Checking #{path.basename} ..."
@detect_output, status = Open3.capture2 command('detect')
- logger.info "Skipping #{path.basename}." unless status == 0
status == 0
end
@@ -17,8 +13,8 @@ def name
def compile
logger.info "Installing #{path.basename}."
- output, ok = run_and_log "#{command('compile')} /tmp/bundler_cache"
- raise "Buildpack compilation step failed:\n#{output}" unless ok
+ ok = system "#{command('compile')} /tmp/bundler_cache"
+ raise "Buildpack compilation step failed:\n" unless ok
end
def release_info
View
9 lib/vcap/staging/plugin/buildpack/plugin.rb
@@ -1,13 +1,11 @@
require 'bundler'
-require "vcap/staging/plugin/shell_helpers"
require 'vcap/staging/plugin/rails3/database_support'
require "uuidtools"
require_relative("buildpack_installer")
class BuildpackPlugin < StagingPlugin
include RailsDatabaseSupport
- include ShellHelpers
def stage_application
Dir.chdir(destination_directory) do
@@ -19,15 +17,12 @@ def stage_application
stage_rails_console if rails_buildpack?
create_startup_script
end
- rescue => e
- logger.error(e)
- raise
end
def clone_buildpack(buildpack_url)
buildpack_path = "#{app_dir}/.buildpacks/#{File.basename(buildpack_url)}"
- output, ok = run_and_log("git clone #{buildpack_url} #{buildpack_path}")
- raise "Failed to git clone buildpack:\n#{output}" unless ok
+ ok = system("git clone #{buildpack_url} #{buildpack_path}")
+ raise "Failed to git clone buildpack" unless ok
BuildpackInstaller.new(Pathname.new(buildpack_path), app_dir, logger)
end
View
11 lib/vcap/staging/plugin/shell_helpers.rb
@@ -1,11 +0,0 @@
-require "open3"
-
-module ShellHelpers
- def run_and_log(command, capture = [:out, :err])
- out, status = Open3.capture2e(command)
-
- logger.info out
-
- [out, status == 0]
- end
-end
View
2 lib/vcap/staging/plugin/staging_plugin.rb
@@ -130,7 +130,7 @@ def logger
log_file = File.expand_path(File.join(log_dir, "staging.log"))
FileUtils.mkdir_p(File.dirname(log_file))
sink_map = VCAP::Logging::SinkMap.new(VCAP::Logging::LOG_LEVELS)
- formatter = VCAP::Logging::Formatter::DelimitedFormatter.new { timestamp; log_level; data }
+ formatter = VCAP::Logging::Formatter::DelimitedFormatter.new { data }
sink_map.add_sink(nil, nil, VCAP::Logging::Sink::StdioSink.new(STDOUT, formatter))
sink_map.add_sink(nil, nil, VCAP::Logging::Sink::FileSink.new(log_file, formatter))
logger = VCAP::Logging::Logger.new('public_logger', sink_map)
View
18 spec/unit/buildpack_spec.rb
@@ -26,14 +26,6 @@
end
end
- it "captures output to the staging log" do
- stage staging_env do |staged_dir|
- staging_log = File.join(staged_dir, 'logs', 'staging.log')
- staging_log_body = File.read(staging_log)
- staging_log_body.should include("-----> Some compilation output")
- end
- end
-
it "puts the environment variables provided by 'release' into the startup script" do
stage staging_env do |staged_dir|
start_script = File.join(staged_dir, 'startup')
@@ -71,16 +63,16 @@
subject { plugin.build_pack }
it "clones the buildpack URL" do
- mock(plugin).run_and_log(anything) do |cmd|
+ mock(plugin).system(anything) do |cmd|
expect(cmd).to match /git clone #{buildpack_url} #{plugin.app_dir}\/.buildpacks/
- ["", true]
+ true
end
subject
end
it "does not try to detect the buildpack" do
- stub(plugin).run_and_log(anything) { ["", true] }
+ stub(plugin).system(anything) { true }
plugin.installers.each do |i|
dont_allow(i).detect
@@ -91,9 +83,9 @@
context "when the cloning fails" do
it "gives up and logs an error" do
- stub(plugin).run_and_log(anything) { ["some failure output", false] }
+ stub(plugin).system(anything) { false }
- expect {subject}.to raise_error("Failed to git clone buildpack:\nsome failure output")
+ expect {subject}.to raise_error("Failed to git clone buildpack")
end
end
end

0 comments on commit 9d40f3f

Please sign in to comment.
Something went wrong with that request. Please try again.