Running rake tasks through capistrano

449 views Asked by At

I am trying to provision a ruby on rails application using vagrant and chef. My environment is set up, I have run bundler and my application has been deployed. However the problem occurs when I try to run rake tasks using capistrano. I can run rake tasks within the release path through ssh, but running the same command using capistrano does not work.

Below is my deploy.rb file.

set :application, 'utrippin.API' 
set :repo_url, '[email protected]:Jaeren/utrippin.git' 
set :repo_tree, 'utrippin.API'

set :deploy_to, "/u/apps/utrippin.API"
set :scm, :git

set :use_sudo, true

namespace :mysql do

task :create do
on roles :all do
within release_path do
  execute "rake db:create"
end
end
end

end 

When running the mysql:create task I get the following error

SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: rake db:create exit status: 127
rake db:create stdout: Nothing written
rake db:create stderr: bash: rake: command not found

Also if I run rake commands using "execute :rake, "db:create"" then it also fails as it fails to connect to the mysql database without a password, even though the correct password is specified in the database.yml file.

I would appreciate any help on how to run rake tasks using capistrano, and an explanation on why I get different results when running in ssh in the same directory with the same user as I do when running using capistrano.

Thanks.

0

There are 0 answers