diff --git a/README.md b/README.md index 2b36a82..2c1ae6e 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ SolrWrapper.wrap port: 8983, | solr_options | (Hash) | | env | (Hash) | | persist | (Boolean) Preserves the data in you collection between startups | - +| print_config | (boolean) | ```ruby solr.with_collection(name: 'collection_name', dir: 'path_to_solr_configs') ``` diff --git a/exe/solr_wrapper b/exe/solr_wrapper index ebf9abd..be665bb 100755 --- a/exe/solr_wrapper +++ b/exe/solr_wrapper @@ -19,6 +19,10 @@ args = OptionParser.new do |opts| options[:verbose] = v end + opts.on("--print-config", "Print the configuration parameters") do |d| + options[:print_config] = true + end + opts.on("--config FILE", "Load configuration from a file") do |v| options[:config] = v end @@ -98,6 +102,12 @@ end instance = SolrWrapper.instance(options) +if options[:print_config] + $stderr.puts '### solr_wrapper configuration ###' + $stderr.puts instance.config.to_yaml + $stderr.puts '#####' +end + case command when 'clean' if instance.started? diff --git a/lib/solr_wrapper/configuration.rb b/lib/solr_wrapper/configuration.rb index 91bcaf0..822d07b 100644 --- a/lib/solr_wrapper/configuration.rb +++ b/lib/solr_wrapper/configuration.rb @@ -150,6 +150,10 @@ def poll_interval options.fetch(:poll_interval, 1) end + def tmp_save_dir + options[:tmp_save_dir] + end + private def self.slice(source, *keys) diff --git a/lib/solr_wrapper/settings.rb b/lib/solr_wrapper/settings.rb index 80dc565..99b27c9 100644 --- a/lib/solr_wrapper/settings.rb +++ b/lib/solr_wrapper/settings.rb @@ -20,6 +20,25 @@ def initialize(static_config) @static_config = static_config end + def to_yaml(*args) + static_config.options.merge({ + version: version, + verbose: verbose?, + download_dir: download_dir, + host: host, + zookeeper_host: zookeeper_host, + port: port, + zookeeper_port: zookeeper_port, + url: url, + instance_dir: instance_dir, + download_url: download_url, + solr_zip_path: solr_zip_path, + version_file: version_file, + mirror_url: default_download_url.gsub(%r{/lucene/solr.*}, ''), + tmp_save_dir: tmp_save_dir + }).to_yaml(*args) + end + ## # Get the host this Solr instance is bound to def host @@ -27,7 +46,7 @@ def host end def zookeeper_host - @zookeeper_host ||= static_config.zookeeper_port + @zookeeper_host ||= static_config.zookeeper_host @zookeeper_host ||= host end @@ -77,6 +96,7 @@ def solr_binary end def tmp_save_dir + @tmp_save_dir ||= static_config.tmp_save_dir @tmp_save_dir ||= Dir.mktmpdir end