Permalink
Browse files

Run Rails Console from buildpack app dir

Change-Id: Ie2ac6de9bc10f708637c4a27ad180e37b62d9523
  • Loading branch information...
1 parent 9f6cef7 commit 78d2dbeb55f18cb41409269224e3f979e8edadce Jennifer Hickey and Tim Labeeuw committed Feb 12, 2013
Showing with 8 additions and 6 deletions.
  1. +6 −4 lib/vcap/staging/plugin/buildpack/plugin.rb
  2. +2 −2 spec/unit/buildpack_spec.rb
@@ -74,9 +74,9 @@ def rails_buildpack?
def stage_rails_console
#Copy cf-rails-console to app
- cf_rails_console_dir = destination_directory + '/cf-rails-console'
+ cf_rails_console_dir = app_dir + '/cf-rails-console'
FileUtils.mkdir_p(cf_rails_console_dir)
- FileUtils.cp_r(File.expand_path('../resources/cf-rails-console', __FILE__), destination_directory)
+ FileUtils.cp_r(File.expand_path('../resources/cf-rails-console', __FILE__), app_dir)
#Generate console access file for caldecott access
config_file = cf_rails_console_dir + '/.consoleaccess'
data = {'username' => UUIDTools::UUID.random_create.to_s,'password' => UUIDTools::UUID.random_create.to_s}
@@ -103,9 +103,11 @@ def startup_script
if rails_buildpack?
script_content += <<-BASH
if [ -n "$VCAP_CONSOLE_PORT" ]; then
- bundle exec ruby cf-rails-console/rails_console.rb >> logs/console.log 2>> logs/console.log &
+ cd app
+ bundle exec ruby cf-rails-console/rails_console.rb >> ../logs/console.log 2>> ../logs/console.log &
CONSOLE_STARTED=$!
- echo "$CONSOLE_STARTED" >> console.pid
+ echo "$CONSOLE_STARTED" >> ../console.pid
+ cd ..
fi
BASH
end
@@ -183,8 +183,8 @@
it "puts the necessary files in the app" do
stage staging_env do |staged_dir|
packages_with_start_script(staged_dir, "bundle exec rails server --from-buildpack=true")
- expect(File.exists?(File.join(staged_dir, "cf-rails-console/rails_console.rb"))).to be_true
- config_file_contents = YAML.load_file(File.join(staged_dir, "cf-rails-console/.consoleaccess"))
+ expect(File.exists?(File.join(staged_dir, "app", "cf-rails-console/rails_console.rb"))).to be_true
+ config_file_contents = YAML.load_file(File.join(staged_dir, "app", "cf-rails-console/.consoleaccess"))
expect(config_file_contents.keys).to match_array(["username", "password"])
end
end

0 comments on commit 78d2dbe

Please sign in to comment.