我正在使用Sunspot Solr,并且我正在编写一个Capistrano任务来启动/停止它。
namespace :sunspot do
task :start, :roles => :app do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:start"
end
end然而,当我运行这个任务时,我得到了找不到Java的错误:
*** [err :: example.com] /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/lib/sunspot/solr/java.rb:5:in ``': No such file or directory - java -version (Errno::ENOENT)
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/lib/sunspot/solr/java.rb:5:in `installed?'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/lib/sunspot/solr/server.rb:200:in `ensure_java_installed'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/lib/sunspot/solr/server.rb:27:in `initialize'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/bin/sunspot-solr:16:in `new'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/gems/sunspot_solr-1.3.3/bin/sunspot-solr:16:in `<top (required)>'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/bin/sunspot-solr:23:in `load'
*** [err :: example.com] from /home/user/deploy/project/shared/bundle/ruby/1.9.1/bin/sunspot-solr:23:in `<main>'
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@project' -c 'cd /home/user/deploy/project/current && RAILS_ENV=staging bundle exec rake sunspot:solr:start'" on example.comSunspot的Java检查代码是here。
如果我在服务器上手动运行cd /home/user/deploy/project/current && RAILS_ENV=staging bundle exec rake sunspot:solr:start,它会按预期工作。如果命令是通过Capistrano调用的,我不知道为什么Java不存在。
发布于 2013-06-18 18:21:14
在我的服务器上,Java路径是在`/etc/profile‘脚本中加载的。
但是,Capistrano不会加载该脚本。
根据this discussion的说法,在Capistrano deploy.rb文件中设置它将确保它的外壳加载配置文件脚本,该脚本的术语是为我设置Java path。
default_run_options[:shell] = '/bin/bash --login'
https://stackoverflow.com/questions/14997426
复制相似问题