Commit 44220b5f274f6482c646489c9f18c9fb8b6ae0fc

Authored by Rodrigo Souto
1 parent 01120b97

Extending solr config to accept data_path

plugins/solr/config/solr.yml
... ... @@ -1,25 +0,0 @@
1   -# Config file for the acts_as_solr plugin.
2   -#
3   -# If you change the host or port number here, make sure you update
4   -# them in your Solr config file
5   -
6   -# No change is needed to support multitenancy. Only one solr environment will be used.
7   -# Just remember to use 'rake multitenancy:reindex' for reindexation.
8   -
9   -production:
10   - url: http://127.0.0.1:8983/solr
11   - jvm_options: -server -Xmx192M -Xms64M
12   - timeout: 0
13   -
14   -development:
15   - url: http://0.0.0.0:8982/solr
16   - jvm_options: -server -Xmx128M -Xms16M
17   - timeout: 0
18   -
19   -test: &TEST
20   - url: http://0.0.0.0:8981/solr
21   - jvm_options: -server -Xmx128M -Xms16M
22   - timeout: 0
23   -
24   -cucumber:
25   - <<: *TEST
plugins/solr/config/solr.yml.dist
... ... @@ -10,6 +10,7 @@ production:
10 10 url: http://127.0.0.1:8983/solr
11 11 jvm_options: -server -Xmx192M -Xms64M
12 12 timeout: 0
  13 + data_path: /var/lib/noosfero-data/solr/index
13 14  
14 15 development:
15 16 url: http://0.0.0.0:8982/solr
... ...
plugins/solr/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb
... ... @@ -6,6 +6,7 @@ require &#39;net/http&#39;
6 6  
7 7 dir = File.dirname(__FILE__)
8 8 SOLR_PATH = File.expand_path("#{dir}/../solr") unless defined? SOLR_PATH
  9 +config = YAML::load_file(RAILS_ROOT+'/plugins/solr/config/solr.yml')
9 10  
10 11 unless defined? RAILS_ROOT
11 12 # define RAILS_ROOT for test environment
... ... @@ -21,7 +22,7 @@ unless defined? SOLR_PIDS_PATH
21 22 SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{RAILS_ROOT}/tmp/pids"
22 23 end
23 24 unless defined? SOLR_DATA_PATH
24   - SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || "#{RAILS_ROOT}/solr/#{ENV['RAILS_ENV']}"
  25 + SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || config[ENV['RAILS_ENV']]['data_path'] || "#{RAILS_ROOT}/solr/#{ENV['RAILS_ENV']}"
25 26 end
26 27 unless defined? SOLR_CONFIG_PATH
27 28 SOLR_CONFIG_PATH = ENV["SOLR_CONFIG_PATH"] || "#{SOLR_PATH}/solr"
... ... @@ -31,7 +32,6 @@ unless defined? SOLR_PID_FILE
31 32 end
32 33  
33 34 unless defined? SOLR_PORT
34   - config = YAML::load_file(RAILS_ROOT+'/plugins/solr/config/solr.yml')
35 35 raise("No solr environment defined for RAILS_ENV = #{ENV['RAILS_ENV'].inspect}") unless config[ENV['RAILS_ENV']]
36 36  
37 37 SOLR_HOST = ENV['HOST'] || URI.parse(config[ENV['RAILS_ENV']]['url']).host
... ...