Skip to content

Instantly share code, notes, and snippets.

@thoolihan
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoolihan/b8c19e0f9ced5dbd88aa to your computer and use it in GitHub Desktop.
Save thoolihan/b8c19e0f9ced5dbd88aa to your computer and use it in GitHub Desktop.
Manage an ElasticSearch Cluster on OS X With LaunchAgents
#!/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
@thoolihan
Copy link
Author

put this in /usr/local/bin and run "chmod 755 /usr/local/bin/es_cluster"

@thoolihan
Copy link
Author

usage is

to start all:
es_cluster

to stop all:
es_cluster down

@KBalderson
Copy link

Nice script. Would it make sense to add an init command that sets up the plist files?

@thoolihan
Copy link
Author

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