Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cape Always Runs the Mirrorred Rake Tasks Under ${current_path} #9

Closed
LeesTimeDotCom opened this issue Sep 20, 2012 · 2 comments
Closed

Comments

@LeesTimeDotCom
Copy link

Hi,

I have this in my config/deploy.rb file:

...

namespace :rake_tasks do
  # Use an argument with the Cape block, if you want to or need to.
  Cape do |cape|
    cape.mirror_rake_tasks :db, :roles => :app do |env| # Only mirror the :db tasks in Rake, and set the RAILS_ENV variable
        env['RAILS_ENV'] = deploy_env
    end 
  end 
end
...

before 'deploy:assets:precompile', 'deploy:symlink_database'
after 'deploy:symlink_database', 'deploy:migrate'
after 'deploy:migrate', 'rake_tasks:db:seed'

...

but when it seems the mirror rake tasks "db:seed" cannot be run under ${current_path}, because at that time, the current symlink has not been created. see the log:

...
   triggering after callbacks for `deploy:update_code'
  * executing `deploy:assets:precompile'
    triggering before callbacks for `deploy:assets:precompile'
  * executing `deploy:symlink_database'
  * executing "ln -s /usr/website/rosettareader/shared/db/production.sqlite3 /usr/website/rosettareader/releases/20120920195322/db/production.sqlite3"
    servers: ["dragon"]
    [dragon] executing command
    command finished in 310ms
    triggering after callbacks for `deploy:symlink_database'
  * executing `deploy:migrate'
  * executing "cd /usr/website/rosettareader/releases/20120920195322 && bundle exec rake RAILS_ENV=production  db:migrate"
    servers: ["dragon"]
    [dragon] executing command
    command finished in 10669ms
    triggering after callbacks for `deploy:migrate'
  * executing `rake_tasks:db:seed'
  * executing "cd /usr/website/rosettareader/current && /usr/bin/env bundle exec rake db:seed RAILS_ENV=\"production\""
    servers: ["dragon"]
    [dragon] executing command
*** [err :: dragon] bash: line 0: cd: /usr/website/rosettareader/current: No such file or directory
    command finished in 313ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /usr/website/rosettareader/releases/20120920195322; true"
    servers: ["dragon"]
    [dragon] executing command
    command finished in 359ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2-p320' -c 'cd /usr/website/rosettareader/current && /usr/bin/env bundle exec rake db:seed RAILS_ENV=\"production\"'" on dragon

See:

*** [err :: dragon] bash: line 0: cd: /usr/website/rosettareader/current: No such file or directory

So how can I run a mirrorred rake tasks under ${release_path}?

@njonsson
Copy link
Owner

njonsson commented Oct 3, 2012

A great suggestion. You are correct that Cape assumes that every Rake task should be run from the directory of the current deployment (see http://github.com/njonsson/cape/blob/master/lib/cape/capistrano.rb#L122).

I will need to consider carefully how best to expose this as a configuration. Your thoughts on this are welcome.

@njonsson
Copy link
Owner

njonsson commented Mar 7, 2013

The new DSL is available in bd5a6aa and v1.7.0. It allows you to deal with this issue gracefully, changing directories for a particular task or tasks.

@njonsson njonsson closed this as completed Mar 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants