Commit 500519946fd09dce6b003153eef0164e25eb05ba
1 parent
1832d72a
Exists in
master
and in
29 other branches
Revert "Revert "Added begin/rescue when trying to kill solr""
This reverts commit 9eb8fc55fe41727f89d9a9b0b77491521d92d36d.
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
| ... | ... | @@ -66,13 +66,19 @@ namespace :solr do |
| 66 | 66 | require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment") |
| 67 | 67 | fork do |
| 68 | 68 | if File.exists?(SOLR_PID_FILE) |
| 69 | + killed = false | |
| 69 | 70 | File.open(SOLR_PID_FILE, "r") do |f| |
| 70 | 71 | pid = f.readline |
| 71 | - Process.kill('TERM', pid.to_i) | |
| 72 | + begin | |
| 73 | + Process.kill('TERM', pid.to_i) | |
| 74 | + killed = true | |
| 75 | + rescue | |
| 76 | + puts "Solr could not be found at pid #{pid.to_i}. Removing pid file." | |
| 77 | + end | |
| 72 | 78 | end |
| 73 | 79 | File.unlink(SOLR_PID_FILE) |
| 74 | 80 | Rake::Task["solr:destroy_index"].invoke if ENV['RAILS_ENV'] == 'test' |
| 75 | - puts "Solr shutdown successfully." | |
| 81 | + puts "Solr shutdown successfully." if killed | |
| 76 | 82 | else |
| 77 | 83 | puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." |
| 78 | 84 | end | ... | ... |