From 297b59e2697299b95cafcdd0e8f981d7f3866cf7 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Mon, 25 Apr 2011 13:23:26 +0200 Subject: 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 --- Library/Formula/elasticsearch.rb | 100 ++++++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 12 deletions(-) (limited to 'Library/Formula') 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 + + + + + KeepAlive + + Label + org.elasticsearch + ProgramArguments + + #{bin}/elasticsearch + -f + -D es.config=#{prefix}/config/elasticsearch.yml + -p #{var}/run/elasticsearch.pid + + RunAtLoad + + UserName + #{`whoami`.chomp} + WorkingDirectory + #{var} + StandardErrorPath + #{var}/log/elasticsearch.log + StandardOutPath + #{var}/log/elasticsearch.log + + + PLIST end end -- cgit v1.2.3