Last active
August 29, 2015 14:08
-
-
Save thoolihan/b8c19e0f9ced5dbd88aa to your computer and use it in GitHub Desktop.
Manage an ElasticSearch Cluster on OS X With LaunchAgents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
apply () { | |
for node in '' 2 3 | |
do | |
launchctl $1 ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch${node}.plist | |
done | |
} | |
status () { | |
ps ax | grep elasticsearch | grep -v "grep" | |
curl 'http://localhost:9200/?pretty' | |
curl 'http://localhost:9200/_cluster/health?pretty' | |
} | |
es_kill () { | |
jps | grep "Elasticsearch" | cut -f1 -d' ' | xargs kill | |
} | |
case $1 in | |
'down') | |
apply 'unload' | |
;; | |
'status') | |
status | |
;; | |
'kill') | |
es_kill | |
;; | |
*) | |
apply 'load' | |
;; | |
esac |
usage is
to start all:
es_cluster
to stop all:
es_cluster down
Nice script. Would it make sense to add an init command that sets up the plist files?
Good idea, could write it from a template
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
put this in /usr/local/bin and run "chmod 755 /usr/local/bin/es_cluster"