I want to run a rake task (migrate) contained in my Rakefile in my Sinatra app. I am using Mina to deploy. rake migrate
works great if I run it on the server or on my development, but I cannot get Mina to execute the task.
My current deploy looks like this within config/deploy.rb
task :deploy => :environment do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
to :launch do
queue "sudo /opt/nginx/sbin/nginx -s reload"
end
end
end
I tried both queue "rake migrate"
and queue "#{rake} migrate"
within the deploy block and within the launch block but it always complains bash: command not found
Mina uses ssh
to run remote commands. That means that the commands run in a different environment as when you log in. This is causing problems with rvm
and rbenv
as they are not initialised properly. Luckily, mina
has rvm
support, you just have to set it up:
require 'mina/rvm'
task :environment do
invoke :'rvm:use[ruby-1.9.3-p125@gemset_name]'
end
task :deploy => :environment do
...
end
You can do a similar thing for rbenv (documentation)