Heroku Bonsai с драгоценным камнем 'bonsai-asticsearch-rails' все еще ищет порт 9200
Я следовал инструкциям Heroku по настройке Bonsai Elasticsearch:
https://devcenter.heroku.com/articles/bonsai
со всем этим в моем Gemfile:
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'bonsai-elasticsearch-rails'
Однако, когда я все еще получаю следующую ошибку соединения при запуске:
heroku run bundle exec rake environment elasticsearch:import:model CLASS='class' FORCE=true --trace
- - returns - -
rake aborted!
Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 9200
Elasticsearch работает локально, я не могу заставить его работать на Heroku.
Моя модель:
class Property < ActiveRecord::Base
# Search
Elasticsearch::Model.client = Elasticsearch::Client.new log: true
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
end
Property.import
У меня есть файл граблей: lib / tasks /asticsearch.rake
require 'elasticsearch/rails/tasks/import'
Я тоже использую Devise, но не думаю, что это влияет на это. На Rails 4.1, Ruby 2.1.2.
Какие-либо предложения?
** редактировать **
Я достал драгоценный камень bonsai -asticsearch-rails и добавил: config/initializers/bonsai.rb
Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL']
По-прежнему сталкиваюсь с той же ошибкой, ища порт 9200
heroku run bundle exec rake environment elasticsearch:import:model CLASS='Property' FORCE=true --trace
Running `bundle exec rake environment elasticsearch:import:model CLASS=Property FORCE=true --trace` attached to terminal... up, run.8668
** Invoke environment (first_time)
** Execute environment
** Invoke elasticsearch:import:model (first_time)
** Execute elasticsearch:import:model
(1.5ms) SELECT COUNT(*) FROM "properties"
2014-10-07 22:39:25 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {:host=>"localhost", :port=>"9200", :protocol=>"http"}
[!!!] Error when deleting the index: Faraday::ConnectionFailed
Connection refused - connect(2) for "localhost" port 9200
2014-10-07 22:39:25 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {:host=>"localhost", :port=>"9200", :protocol=>"http"}
2014-10-07 22:39:25 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {:host=>"localhost", :port=>"9200", :protocol=>"http"}
[!!!] Error when creating the index: Faraday::ConnectionFailed
Connection refused - connect(2) for "localhost" port 9200
Property Load (1.8ms) SELECT "properties".* FROM "properties" ORDER BY "properties"."id" ASC LIMIT 1000
2014-10-07 22:39:25 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {:host=>"localhost", :port=>"9200", :protocol=>"http"}
rake aborted!
Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 9200
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `open'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:878:in `connect'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:1369:in `request'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/base.rb:187:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/base.rb:187:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/client.rb:104:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-api-1.0.5/lib/elasticsearch/api/actions/bulk.rb:81:in `bulk'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/importing.rb:120:in `block in import'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/adapters/active_record.rb:96:in `block in __find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/relation/batches.rb:125:in `find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/querying.rb:9:in `find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/proxy.rb:80:in `method_missing'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/adapters/active_record.rb:95:in `__find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/importing.rb:119:in `import'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-rails-0.1.6/lib/elasticsearch/rails/tasks/import.rb:63:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/2.1.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.1.0/bin/rake:23:in `<main>'
Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 9200
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `open'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:878:in `connect'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:1369:in `request'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
/app/vendor/bundle/ruby/2.1.0/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/base.rb:187:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/base.rb:187:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-transport-1.0.5/lib/elasticsearch/transport/client.rb:104:in `perform_request'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-api-1.0.5/lib/elasticsearch/api/actions/bulk.rb:81:in `bulk'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/importing.rb:120:in `block in import'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/adapters/active_record.rb:96:in `block in __find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/relation/batches.rb:125:in `find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/querying.rb:9:in `find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/proxy.rb:80:in `method_missing'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/adapters/active_record.rb:95:in `__find_in_batches'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-model-0.1.6/lib/elasticsearch/model/importing.rb:119:in `import'
/app/vendor/bundle/ruby/2.1.0/gems/elasticsearch-rails-0.1.6/lib/elasticsearch/rails/tasks/import.rb:63:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/2.1.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => elasticsearch:import:model
** редактировать 2 **
Та же ошибка при использовании:
elasticsearch-model 0.1.4 or 0.1.6
elasticsearch-rails 0.1.4 or 0.1.6
2 ответа
Обнаружил, что эта строка в моей модели перезаписывает другие настройки:
Elasticsearch::Model.client = Elasticsearch::Client.new log: true
Эта ошибка исчезнет, если я установлю это на это:
Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL'], log: true
Спасибо Нику и Робу за помощь. Теперь перейдем к следующей ошибке...
** обновление 12-29-2014 Я столкнулся с той же ошибкой при запуске этого из новой установки, исправил это с помощью ввода
$ elasticsearch
в консоли, чтобы начать поиск. Надеюсь, это поможет кому-то еще.
Я сделал:
/etc/init.d/elasticsearch restart
и это решило это для меня.