From a08d5f1b519fe11bc2a1c26c96801c0b78e2739b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 4 Dec 2017 02:12:55 +0100 Subject: [PATCH] Improved error handling. --- lib/search_index_backend.rb | 1 + lib/tasks/search_index_es.rake | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index 6547e491f..d909b8ed6 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -12,6 +12,7 @@ info about used search index machine def self.info url = Setting.get('es_url').to_s + return if url.blank? Rails.logger.info "# curl -X GET \"#{url}\"" response = UserAgent.get( url, diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake index e92ecd180..7a68ab5c6 100644 --- a/lib/tasks/search_index_es.rake +++ b/lib/tasks/search_index_es.rake @@ -16,8 +16,12 @@ namespace :searchindex do puts 'create indexes...' # es with mapper-attachments plugin - number = SearchIndexBackend.info['version']['number'].to_s - if number =~ /^[2-4]\./ || number =~ /^5\.[0-5]\./ + info = SearchIndexBackend.info + number = nil + if info.present? + number = info['version']['number'].to_s + end + if number.blank? || number =~ /^[2-4]\./ || number =~ /^5\.[0-5]\./ # create indexes SearchIndexBackend.index(