我正在尝试使用 Capistrano 部署 Sunspot Solr。我一直在根据这个要点进行设置:https ://gist.github.com/doitian/1795439 。
部署.rb
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
desc "Migrate Database"
task :migrate_db do
run "cd #{current_path} && rake db:migrate RAILS_ENV=production"
run "touch #{current_path}/tmp/restart.txt"
end
desc "Create Solr Directory"
task :setup_solr_data_dir do
run "mkdir -p #{shared_path}/solr/data"
end
end
namespace :solr do
desc "start solr"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
end
desc "stop solr"
task :stop, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr stop --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
end
desc "reindex the whole database"
task :reindex, :roles => :app do
stop
run "rm -rf #{shared_path}/solr/data"
start
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:reindex"
end
end
after "deploy", "deploy:cleanup", "deploy:migrate_db", 'deploy:setup_solr_data_dir', 'solr:stop', 'solr:reindex', 'solr:start'
我已经为在 sunspot.yml 中托管我的生产应用程序的内部服务器设置了 IP:
production:
solr:
hostname: [My Server IP]
port: 8983
log_level: WARNING
# read_timeout: 2
# open_timeout: 0.5
当我尝试运行cap deploy时,我收到以下错误:
* 2013-04-24 08:28:04 executing `solr:stop'
* executing "cd /home/username/apps/appname/current && RAILS_ENV=production bundle exec sunspot-solr stop --port=8983 --data-directory=/home/username/apps/appname/shared/solr/data --pid-dir=/home/datacomm/apps/appname/shared/pids"
servers: ["0.0.0.0"]
[0.0.0.0] executing command
** [out :: 0.0.0.0] java version "1.7.0_15"
** [out :: 0.0.0.0]
** [out :: 0.0.0.0] OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.04.1)
** [out :: 0.0.0.0]
** [out :: 0.0.0.0] OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
** [out :: 0.0.0.0]
** [out :: 0.0.0.0] **No PID file at /home/username/apps/appname/shared/pids/sunspot-solr.pid**
** [out :: 0.0.0.0]
command finished in 990ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /home/username/apps/appname/current && RAILS_ENV=production bundle exec sunspot-solr stop --port=8983 --data-directory=/home/username/apps/appname/shared/solr/data --pid-dir=/home/username/apps/appname/shared/pids'" on 0.0.0.0
我错过了什么?任何帮助表示赞赏。