2010-04-09 13:34:11 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class Elasticsearch < Formula
|
2012-01-16 16:30:20 +00:00
|
|
|
url 'https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz'
|
2011-05-13 08:21:58 +00:00
|
|
|
homepage 'http://www.elasticsearch.org'
|
2012-01-16 16:30:20 +00:00
|
|
|
md5 'c4de29abf930693b0a4290df3250e128'
|
2011-01-13 19:21:49 +00:00
|
|
|
|
2011-10-02 20:45:20 +00:00
|
|
|
def cluster_name
|
|
|
|
"elasticsearch_#{ENV['USER']}"
|
|
|
|
end
|
|
|
|
|
2011-04-25 11:23:26 +00:00
|
|
|
def install
|
|
|
|
# Remove Windows files
|
|
|
|
rm_f Dir["bin/*.bat"]
|
2011-11-17 00:09:36 +00:00
|
|
|
# Move JARs from lib to libexec according to homebrew conventions
|
|
|
|
libexec.install Dir['lib/*.jar']
|
|
|
|
(libexec+'sigar').install Dir['lib/sigar/*.jar']
|
2011-01-13 19:21:49 +00:00
|
|
|
|
2011-04-25 11:23:26 +00:00
|
|
|
# Install everything directly into folder
|
|
|
|
prefix.install Dir['*']
|
|
|
|
|
2011-10-02 20:45:20 +00:00
|
|
|
# Set up ElasticSearch for local development:
|
2011-04-25 11:23:26 +00:00
|
|
|
inreplace "#{prefix}/config/elasticsearch.yml" do |s|
|
2011-10-02 20:45:20 +00:00
|
|
|
|
|
|
|
# 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/"
|
2011-04-25 11:23:26 +00:00
|
|
|
end
|
|
|
|
|
2011-11-18 21:22:45 +00:00
|
|
|
inreplace "#{bin}/elasticsearch.in.sh" do |s|
|
2011-11-17 00:09:36 +00:00
|
|
|
# Replace CLASSPATH paths to use libexec instead of lib
|
|
|
|
s.gsub! /ES_HOME\/lib\//, "ES_HOME/libexec/"
|
|
|
|
end
|
|
|
|
|
2011-11-18 21:22:45 +00:00
|
|
|
inreplace "#{bin}/elasticsearch" do |s|
|
2011-11-17 00:09:36 +00:00
|
|
|
# Set ES_HOME to prefix value
|
|
|
|
s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
|
|
|
|
end
|
|
|
|
|
2011-11-23 22:40:12 +00:00
|
|
|
inreplace "#{bin}/plugin" do |s|
|
|
|
|
# Set ES_HOME to prefix value
|
|
|
|
s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
|
|
|
|
# Replace CLASSPATH paths to use libexec instead of lib
|
|
|
|
s.gsub! /-cp \".*\"/, '-cp "$ES_HOME/libexec/*"'
|
|
|
|
end
|
|
|
|
|
2011-10-02 20:45:20 +00:00
|
|
|
# Write .plist file for `launchd`
|
2011-04-25 11:23:26 +00:00
|
|
|
(prefix+'org.elasticsearch.plist').write startup_plist
|
2011-09-02 21:41:57 +00:00
|
|
|
(prefix+'org.elasticsearch.plist').chmod 0644
|
2011-01-13 19:21:49 +00:00
|
|
|
end
|
|
|
|
|
2011-04-25 11:23:26 +00:00
|
|
|
def caveats
|
|
|
|
<<-EOS.undent
|
|
|
|
If this is your first install, automatically load ElasticSearch on login with:
|
|
|
|
mkdir -p ~/Library/LaunchAgents
|
|
|
|
ln -nfs #{prefix}/org.elasticsearch.plist ~/Library/LaunchAgents/
|
|
|
|
launchctl load -wF ~/Library/LaunchAgents/org.elasticsearch.plist
|
2010-04-09 13:34:11 +00:00
|
|
|
|
2011-04-25 11:23:26 +00:00
|
|
|
If this is an upgrade and you already have the org.elasticsearch.plist loaded:
|
|
|
|
launchctl unload -w ~/Library/LaunchAgents/org.elasticsearch.plist
|
|
|
|
ln -nfs #{prefix}/org.elasticsearch.plist ~/Library/LaunchAgents/
|
|
|
|
launchctl load -wF ~/Library/LaunchAgents/org.elasticsearch.plist
|
|
|
|
|
|
|
|
To stop the ElasticSearch daemon:
|
|
|
|
launchctl unload -wF ~/Library/LaunchAgents/org.elasticsearch.plist
|
|
|
|
|
|
|
|
To start ElasticSearch manually:
|
|
|
|
elasticsearch -f -D es.config=#{prefix}/config/elasticsearch.yml
|
|
|
|
|
2011-10-02 20:45:20 +00:00
|
|
|
See the 'elasticsearch.yml' file for configuration options.
|
2011-04-25 11:23:26 +00:00
|
|
|
|
|
|
|
You'll find the ElasticSearch log here:
|
2011-10-02 20:45:20 +00:00
|
|
|
open #{var}/log/elasticsearch/#{cluster_name}.log
|
2011-04-25 11:23:26 +00:00
|
|
|
|
2011-10-02 20:45:20 +00:00
|
|
|
The folder with cluster data is here:
|
|
|
|
open #{var}/elasticsearch/#{cluster_name}/
|
2011-04-25 11:23:26 +00:00
|
|
|
|
|
|
|
You should see ElasticSearch running:
|
|
|
|
open http://localhost:9200/
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
2011-01-13 19:21:49 +00:00
|
|
|
|
2011-04-25 11:23:26 +00:00
|
|
|
def startup_plist
|
|
|
|
<<-PLIST.undent
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<true/>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>org.elasticsearch</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{bin}/elasticsearch</string>
|
|
|
|
<string>-f</string>
|
|
|
|
<string>-D es.config=#{prefix}/config/elasticsearch.yml</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
2011-10-02 20:45:20 +00:00
|
|
|
<string>#{ENV['USER']}</string>
|
2011-04-25 11:23:26 +00:00
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{var}</string>
|
|
|
|
<key>StandardErrorPath</key>
|
2011-10-02 20:45:20 +00:00
|
|
|
<string>/dev/null</string>
|
2011-04-25 11:23:26 +00:00
|
|
|
<key>StandardOutPath</key>
|
2011-10-02 20:45:20 +00:00
|
|
|
<string>/dev/null</string>
|
2011-04-25 11:23:26 +00:00
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
PLIST
|
2010-04-09 13:34:11 +00:00
|
|
|
end
|
|
|
|
end
|