Commit 4e61bfb7a04ef3a7171343867aca05c4ce401197

Authored by Braulio Bhavamitra
Committed by Daniela Feitosa
1 parent e4b948f4

Added begin/rescue when trying to kill solr

(ActionItem1958)
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
... ...