Commit 4e61bfb7a04ef3a7171343867aca05c4ce401197
Committed by
Daniela Feitosa
1 parent
e4b948f4
Exists in
master
and in
29 other branches
Added begin/rescue when trying to kill solr
(ActionItem1958)
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,13 +66,19 @@ namespace :solr do | ||
66 | require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment") | 66 | require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment") |
67 | fork do | 67 | fork do |
68 | if File.exists?(SOLR_PID_FILE) | 68 | if File.exists?(SOLR_PID_FILE) |
69 | + killed = false | ||
69 | File.open(SOLR_PID_FILE, "r") do |f| | 70 | File.open(SOLR_PID_FILE, "r") do |f| |
70 | pid = f.readline | 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 | end | 78 | end |
73 | File.unlink(SOLR_PID_FILE) | 79 | File.unlink(SOLR_PID_FILE) |
74 | Rake::Task["solr:destroy_index"].invoke if ENV['RAILS_ENV'] == 'test' | 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 | else | 82 | else |
77 | puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." | 83 | puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." |
78 | end | 84 | end |