Deploying Rails (4) app with Chef


#1

Hi,

I have been working my way through deploying a Rails 4 app with
Chef/Vagrant thanks to lots of help from this list. :slight_smile:

Now Chef is saying:

2013-12-14T15:24:03+00:00] INFO: deploy_revision[rapto] migrating apache
with environment RAILS_ENV=‘production’
[2013-12-14T15:24:04+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0
[2013-12-14T15:24:04+00:00] INFO: Removing failed deploy
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1

I can’t run rake to diagnose this because Chef is removing my Rails app
folder. How can I stop Chef from Removing the failed deploy?

Thanks
Rob


#2

Run chef-client with -ldebug and you’ll get the stack trace from rake. A lot of times this is due to not having run ‘bundle’ or a missing database (rake db:create:all.)

Sent from my iPhone

On Dec 14, 2013, at 11:25 AM, Rob Watkin robwatkin@gmail.com wrote:

Hi,

I have been working my way through deploying a Rails 4 app with Chef/Vagrant thanks to lots of help from this list. :slight_smile:

Now Chef is saying:

2013-12-14T15:24:03+00:00] INFO: deploy_revision[rapto] migrating apache with environment RAILS_ENV=‘production’
[2013-12-14T15:24:04+00:00] WARN: Error on deploying /var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1: /usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0
[2013-12-14T15:24:04+00:00] INFO: Removing failed deploy /var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1

I can’t run rake to diagnose this because Chef is removing my Rails app folder. How can I stop Chef from Removing the failed deploy?

Thanks
Rob


#3

Hi Daniel,

Yes I think you’re right. I have now run:

chef-solo --log_level debug -c /tmp/vagrant-chef-1/solo.rb -j

/tmp/vagrant-chef-1/dna.json

and I get:
[2013-12-14T17:19:36+00:00] DEBUG: Ran /usr/local/bundle_wrapper.sh exec
rake db:migrate returned 1
[2013-12-14T17:19:36+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0

But I thought I was running bundle with application_ruby thus:

application “rapto” do

rails do
bundler true
bundle_command "#{base_dir}/bundle_wrapper.sh"
end

Thanks
Rob

On 14 December 2013 17:01, Daniel Condomitti daniel@condomitti.com wrote:

Run chef-client with -ldebug and you’ll get the stack trace from rake. A
lot of times this is due to not having run ‘bundle’ or a missing database
(rake db:create:all.)

Sent from my iPhone

On Dec 14, 2013, at 11:25 AM, Rob Watkin robwatkin@gmail.com wrote:

Hi,

I have been working my way through deploying a Rails 4 app with
Chef/Vagrant thanks to lots of help from this list. :slight_smile:

Now Chef is saying:

2013-12-14T15:24:03+00:00] INFO: deploy_revision[rapto] migrating apache
with environment RAILS_ENV=‘production’
[2013-12-14T15:24:04+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0
[2013-12-14T15:24:04+00:00] INFO: Removing failed deploy
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1

I can’t run rake to diagnose this because Chef is removing my Rails app
folder. How can I stop Chef from Removing the failed deploy?

Thanks
Rob


#4

Hi Daniel,

Sorry, I just re-read your reply. I’ll try and find out how to trigger
db:create

Rob

On 14 December 2013 17:31, Rob Watkin robwatkin@gmail.com wrote:

Hi Daniel,

Yes I think you’re right. I have now run:

chef-solo --log_level debug -c /tmp/vagrant-chef-1/solo.rb -j

/tmp/vagrant-chef-1/dna.json

and I get:
[2013-12-14T17:19:36+00:00] DEBUG: Ran /usr/local/bundle_wrapper.sh exec
rake db:migrate returned 1
[2013-12-14T17:19:36+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0

But I thought I was running bundle with application_ruby thus:

application “rapto” do

rails do
bundler true
bundle_command "#{base_dir}/bundle_wrapper.sh"
end

Thanks
Rob

On 14 December 2013 17:01, Daniel Condomitti daniel@condomitti.comwrote:

Run chef-client with -ldebug and you’ll get the stack trace from rake. A
lot of times this is due to not having run ‘bundle’ or a missing database
(rake db:create:all.)

Sent from my iPhone

On Dec 14, 2013, at 11:25 AM, Rob Watkin robwatkin@gmail.com wrote:

Hi,

I have been working my way through deploying a Rails 4 app with
Chef/Vagrant thanks to lots of help from this list. :slight_smile:

Now Chef is saying:

2013-12-14T15:24:03+00:00] INFO: deploy_revision[rapto] migrating
apache with environment RAILS_ENV=‘production’
[2013-12-14T15:24:04+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0
[2013-12-14T15:24:04+00:00] INFO: Removing failed deploy
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1

I can’t run rake to diagnose this because Chef is removing my Rails app
folder. How can I stop Chef from Removing the failed deploy?

Thanks
Rob


#5

Well this is a chicken and an egg. I can’t execute rake db:create before

application “app_name” do
rails do
etc

because the app hasn’t yet been pulled down. However I can’t work out how
to do it within. The problem is that I am just trying to set this up in my
local Vagrant vm whilst the application_ruby docs discuss pointing to a
live db server.

On 14 December 2013 17:32, Rob Watkin robwatkin@gmail.com wrote:

Hi Daniel,

Sorry, I just re-read your reply. I’ll try and find out how to trigger
db:create

Rob

On 14 December 2013 17:31, Rob Watkin robwatkin@gmail.com wrote:

Hi Daniel,

Yes I think you’re right. I have now run:

chef-solo --log_level debug -c /tmp/vagrant-chef-1/solo.rb -j

/tmp/vagrant-chef-1/dna.json

and I get:
[2013-12-14T17:19:36+00:00] DEBUG: Ran /usr/local/bundle_wrapper.sh exec
rake db:migrate returned 1
[2013-12-14T17:19:36+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0

But I thought I was running bundle with application_ruby thus:

application “rapto” do

rails do
bundler true
bundle_command "#{base_dir}/bundle_wrapper.sh"
end

Thanks
Rob

On 14 December 2013 17:01, Daniel Condomitti daniel@condomitti.comwrote:

Run chef-client with -ldebug and you’ll get the stack trace from rake. A
lot of times this is due to not having run ‘bundle’ or a missing database
(rake db:create:all.)

Sent from my iPhone

On Dec 14, 2013, at 11:25 AM, Rob Watkin robwatkin@gmail.com wrote:

Hi,

I have been working my way through deploying a Rails 4 app with
Chef/Vagrant thanks to lots of help from this list. :slight_smile:

Now Chef is saying:

2013-12-14T15:24:03+00:00] INFO: deploy_revision[rapto] migrating
apache with environment RAILS_ENV=‘production’
[2013-12-14T15:24:04+00:00] WARN: Error on deploying
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1:
/usr/local/bundle_wrapper.sh exec rake db:migrate returned 1, expected 0
[2013-12-14T15:24:04+00:00] INFO: Removing failed deploy
/var/www/releases/2680fd501ac6ab0c76f26da19d45cdee046097f1

I can’t run rake to diagnose this because Chef is removing my Rails
app folder. How can I stop Chef from Removing the failed deploy?

Thanks
Rob


#6

On Saturday, December 14, 2013 at 17:31, Rob Watkin wrote:

Well this is a chicken and an egg. I can’t execute rake db:create before

application “app_name” do
rails do
etc

because the app hasn’t yet been pulled down.
You can put it in the before_deploy callback attribute [1].

[1] https://github.com/poise/application#callback-attributes

–Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal