aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorKarel Minarik2011-04-25 13:23:26 +0200
committerAdam Vandenberg2011-04-25 09:22:38 -0700
commit297b59e2697299b95cafcdd0e8f981d7f3866cf7 (patch)
tree629113e0248fde811a2a659f00a9a66e346d6468 /Library/Formula
parentfb69cc8fe8070514a44b0d1b760edbfb6772c261 (diff)
downloadhomebrew-297b59e2697299b95cafcdd0e8f981d7f3866cf7.tar.bz2
ElasticSearch 0.16.0
Also: * moved data and logs properly into /usr/local/var * added configuration file, added plist and instruction Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/elasticsearch.rb100
1 files changed, 88 insertions, 12 deletions
diff --git a/Library/Formula/elasticsearch.rb b/Library/Formula/elasticsearch.rb
index 19f4c8c36..5cbdf2612 100644
--- a/Library/Formula/elasticsearch.rb
+++ b/Library/Formula/elasticsearch.rb
@@ -1,24 +1,100 @@
require 'formula'
class Elasticsearch < Formula
- url 'https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.15.2.tar.gz'
+ url 'https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.16.0.tar.gz'
homepage 'http://www.elasticsearch.com'
- md5 '6e0e9ea3fcc0e95d2fe490445fb4aa1d'
+ md5 '5d719acd670d9ac3393d436c21bd0b58'
- skip_clean 'libexec/data'
+ def install
+ # Remove Windows files
+ rm_f Dir["bin/*.bat"]
- def startup_script name
- <<-EOS.undent
- #!/bin/bash
- exec #{libexec}/bin/#{name} $@
- EOS
+ # 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
+ inreplace "#{prefix}/config/elasticsearch.yml" do |s|
+ s << <<-EOS.undent
+ cluster:
+ name: elasticsearch
+
+ path:
+ logs: #{var}/log
+ data: #{var}/data
+
+ boostrap:
+ mlockall: true
+ EOS
+ end
+
+ # Write PLIST file for `launchd`
+ (prefix+'org.elasticsearch.plist').write startup_plist
end
+ 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
- def install
- prefix.install %w{LICENSE.txt NOTICE.txt README.textile}
- libexec.install Dir['*']
+ 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
+
+ See the #{prefix}/config/elasticsearch.yml file for configuration.
+
+ You'll find the ElasticSearch log here:
+ #{var}/log/elasticsearch.log
+
+ The folder with all the data is here:
+ #{var}/data/elasticsearch
+
+ You should see ElasticSearch running:
+ open http://localhost:9200/
+
+ EOS
+ end
- (bin+'elasticsearch').write startup_script('elasticsearch')
+ 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>
+ <string>-p #{var}/run/elasticsearch.pid</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>UserName</key>
+ <string>#{`whoami`.chomp}</string>
+ <key>WorkingDirectory</key>
+ <string>#{var}</string>
+ <key>StandardErrorPath</key>
+ <string>#{var}/log/elasticsearch.log</string>
+ <key>StandardOutPath</key>
+ <string>#{var}/log/elasticsearch.log</string>
+ </dict>
+ </plist>
+ PLIST
end
end