diff --git a/Formula/elasticsearch.rb b/Formula/elasticsearch.rb index b97d7fc53ca..0e5bd91ec2f 100644 --- a/Formula/elasticsearch.rb +++ b/Formula/elasticsearch.rb @@ -5,6 +5,10 @@ class Elasticsearch < Formula homepage 'http://www.elasticsearch.org' md5 'be59eaf874280e8f748269531dd0cf07' + def cluster_name + "elasticsearch_#{ENV['USER']}" + end + def install # Remove Windows files rm_f Dir["bin/*.bat"] @@ -12,22 +16,18 @@ class Elasticsearch < Formula # Install everything directly into folder prefix.install Dir['*'] - # Make sure we have support folders in /usr/var - %w( run data/elasticsearch log ).each { |path| (var+path).mkpath } - - # Put basic configuration into config file + # Set up ElasticSearch for local development: inreplace "#{prefix}/config/elasticsearch.yml" do |s| - s << <<-EOS.undent - cluster: - name: elasticsearch - path: - logs: #{var}/log - data: #{var}/data - EOS + # 1. Give the cluster a unique name + s.gsub! /#\s*cluster\.name\: elasticsearch/, "cluster.name: #{cluster_name}" + + # 2. Configure paths + s.gsub! /#\s*path\.data\: [^\n]+/, "path.data: #{var}/elasticsearch/" + s.gsub! /#\s*path\.logs\: [^\n]+/, "path.logs: #{var}/log/elasticsearch/" end - # Write PLIST file for `launchd` + # Write .plist file for `launchd` (prefix+'org.elasticsearch.plist').write startup_plist (prefix+'org.elasticsearch.plist').chmod 0644 end @@ -50,13 +50,13 @@ class Elasticsearch < Formula To start ElasticSearch manually: elasticsearch -f -D es.config=#{prefix}/config/elasticsearch.yml - See the #{prefix}/config/elasticsearch.yml file for configuration. + See the 'elasticsearch.yml' file for configuration options. You'll find the ElasticSearch log here: - #{var}/log/elasticsearch.log + open #{var}/log/elasticsearch/#{cluster_name}.log - The folder with all the data is here: - #{var}/data/elasticsearch + The folder with cluster data is here: + open #{var}/elasticsearch/#{cluster_name}/ You should see ElasticSearch running: open http://localhost:9200/ @@ -79,18 +79,17 @@ class Elasticsearch < Formula #{bin}/elasticsearch -f -D es.config=#{prefix}/config/elasticsearch.yml - -p #{var}/run/elasticsearch.pid RunAtLoad UserName - #{`whoami`.chomp} + #{ENV['USER']} WorkingDirectory #{var} StandardErrorPath - #{var}/log/elasticsearch.log + /dev/null StandardOutPath - #{var}/log/elasticsearch.log + /dev/null PLIST