ElasticSearch: formula cleanup
This commit introduces couple of breaking, but important changes for ElasticSearch: 1. The cluster is given a reasonably unique, though human-friendly name, based on the current user login name (`ENV['USER']`). This minimizes conflicts and dubious [MasterNotDiscoveredException] errors when running a development cluster eg. within an office, on multiple workstations, with open firewalls. 2. This means the _path to data has changed_ and users will have to move it manually to new location. It should be safe to do so, while ES is not running. 3. The log files location also changed to a more appropriate one. 4. Standard error and ouput streams were redirected to /dev/null within the `plist` definition, since ES provides enough logging already. The changes should be forward compatible with the complete rewrite of ES config file in <https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml>. Closes Homebrew/homebrew#7946. Signed-off-by: Jack Nagel <jacknagel@gmail.com>master
parent
ed2dcf0517
commit
be31b45690
|
@ -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
|
|||
<string>#{bin}/elasticsearch</string>
|
||||
<string>-f</string>
|
||||
<string>-D es.config=#{prefix}/config/elasticsearch.yml</string>
|
||||
<string>-p #{var}/run/elasticsearch.pid</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>UserName</key>
|
||||
<string>#{`whoami`.chomp}</string>
|
||||
<string>#{ENV['USER']}</string>
|
||||
<key>WorkingDirectory</key>
|
||||
<string>#{var}</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>#{var}/log/elasticsearch.log</string>
|
||||
<string>/dev/null</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>#{var}/log/elasticsearch.log</string>
|
||||
<string>/dev/null</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
|
|
Loading…
Reference in New Issue