我想在我的Sinatra应用程序中运行我的Rakefile中包含的rake任务(迁移).我正在使用Mina进行部署.如果我在服务器上或在我的开发上运行它,rake migrate工作得很好,但我无法让Mina执行任务. 我当
我当前的部署在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
我在部署块和启动块内尝试了两个队列“rake migrate”和队列“#{rake} migrate”,但它始终抱怨bash:command not found
Mina使用ssh来运行远程命令.这意味着命令在登录时在不同的环境中运行.这会导致rvm和rbenv出现问题,因为它们未正确初始化.幸运的是,mina有rvm
support,你只需要设置它:
require 'mina/rvm' task :environment do invoke :'rvm:use[ruby-1.9.3-p125@gemset_name]' end task :deploy => :environment do ... end
你可以为rbenv做类似的事情(documentation)