How to Run Rake with --Trace Within Capistrano

How can I run rake with --trace within capistrano?

The best way I found is:

set :rake, "#{rake} --trace"

This way you don't overwrite the rake variable.

For example if you use bundler this is set before to:

"bundle exec rake"

and after to:

"bundle exec rake --trace"

Capistrano: how to run a command-line rake task and rescue only for specific errors?

I don't have answer to your question, but you can ensure that command doesn't try to start solr already running.

run "cd #{current_path} && if [ ! -f #{solr_pid} ]; then RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:start; fi

I assume that there is solr.pid (if solr runs as a deamon it should be there) and solr_pid is path to that pid.

Update: You can also use ps aux to check if solr process is really running:

if ! ps aux | grep -q "[s]olr production" ; then echo 'solr not running'; fi

I am using [s] in grep argument because otherwise ps aux command would catch itself. I am not sure what phrase would be proper to find solr process, so probably you will have to use something more precise.

rails capistrano having problems with rake db:migrate

Its because of ruby conflict. I've faced same error. You will need to use rvm/capistrano gem. I'll paste some code from my cap file which will give you some idea about how to set the ruby version while deploying.

install the gem

gem install rvm-capistrano

in you deploy.rb file add these lines

require 'bundler/capistrano'
require 'rvm/capistrano'

set :rvm_ruby_string, "ruby-1.9.3-p125"
set :rvm_type, 'webadmin'

For more information you can visit this link rvm/capistrano

How can I disable the trace in rake tasks?

The problem has been tracked down to a custom gem that implements a Capistrano Plugin. The gem allows for a different version control system to be used with Capistrano other than the ones they provide (Git, SVN, etc.).

The ultimate issue was that capistrano/lib/capistrano/all.rb has this line:

Rake.application.options.trace = true

This file was being loaded with the Capistrano Plugins, but the default ones are not required until used in the Capfile. When we created a custom gem with a new plugin, we simply added the new gem to our application's Gemfile, which loads the files by default. So our plugin file looked like this:

# custom_gem/lib/capistrano/scm/custom_vc.rb
require 'capistrano/scm/plugin'
class Capistrano::SCM::CustomVC < Capistarno::SCM::Plugin
# ... Mimic the capistrano/lib/capistrano/scm/git.rb in the Capistrano gem.
end

The top line that requires capistrano/scm/plugin was ultimately requiring the capistrano-lib/capistrano/all.rb that was setting trace to be on for all Rake tasks.

The solution was to simply add require: false to our Gemfile for the custom gem.

# Gemfile
group :development do
gem 'capistrano_custom_vc', require: false
end

How to halt a Capistrano deploy from within a task

You should raise a CommandError exception:

error = CommandError.new("An error that should abort and rollback deployment") 
raise error

So no backtrace are shown.

Capistrano deploy fails with rake run (rails3 + rvm)

In order to work correctly, rbenv must override all the ruby and gem-related executables with the shims it provides.

Usually this is done with a startup script (this is why it works when you login to your server) but Capistrano logs in without shell and thus does not run those scripts.

You must add the following to your deploy.rb :

set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}

and do not use anything rvm related on your server, rbenv and rvm really do not like each other

PS : a little more explanation on this topic : http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/

Capistrano rails | undefined method `already_invoked' for Rake::Task when setting rails_env while migrations during gitlab deploy

My guess is that because you are installing the Capistrano Gems in the CI environment manually, there is a version mismatch. If you run bundle install and bundle exec on the CI server, or pin the installed versions, it will probably start working.

One solution I've used for this is to add all of the required deployment gems to a :deployment group in my Gemfile. Then you need to add the following to your deploy.rb:

set :bundle_without, %w{development test deployment}.join(' ')

Then change your script to be:

bundle install --except development test default production ...
bundle exec cap $CI_BUILD_REF_NAME deploy

How to call a Capistrano's task within another Capistrano's task?

my command
invoke 'db_access:copy_production'
was correct.

The problem comes from SSH-KIT which has a bug.
The problem is that Capistrano 3.1 is using ssh-kit version 1.3.
So we have to use Capistrano 3.0.1 until ssh-kit get fixed.

Workaround :

gem uninstall capistrano
gem uninstall capistrano-rails
gem uninstall sshkit
rm Gemfile.lock

Modify Gemfile :

  gem 'capistrano', '~> 3.0.1'
gem 'sshkit', '~> 1.0.0'

Install gems :

bundle install


Related Topics



Leave a reply



Submit