Last active
November 15, 2018 11:41
-
-
Save BenConstable/b64844776e63a52c3e54 to your computer and use it in GitHub Desktop.
Elasticsearch Upstart config
This file contains hidden or 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
# | |
# Elasticsearch Service | |
# | |
# Tested with ES v1.5.2 | |
# | |
# Doesn't currently support a configurable JVM. | |
# | |
# Adapted from the SysVInit script ES provides, which | |
# can be found here: | |
# | |
# https://github.com/elastic/elasticsearch/blob/v1.5.2/src/deb/init.d/elasticsearch | |
# | |
description "Elasticsearch" | |
start on (net-device-up and local-filesystems and runlevel [2345]) | |
stop on runlevel [!2345] | |
respawn | |
respawn limit 10 5 | |
env DEFAULT=/etc/default/elasticsearch | |
env ES_USER=elasticsearch | |
env ES_GROUP=elasticsearch | |
env ES_HOME=/usr/share/elasticsearch | |
env LOG_DIR=/var/log/elasticsearch | |
env DATA_DIR=/var/lib/elasticsearch | |
env WORK_DIR=/tmp/elasticsearch | |
env CONF_DIR=/etc/elasticsearch | |
env CONF_FILE=/etc/elasticsearch/elasticsearch.yml | |
env MAX_MAP_COUNT=262144 | |
env MAX_OPEN_FILES=65535 | |
console output | |
script | |
if [ -f "$DEFAULT" ]; then | |
. "$DEFAULT" | |
fi | |
export ES_HEAP_SIZE | |
export ES_HEAP_NEWSIZE | |
export ES_DIRECT_SIZE | |
export ES_JAVA_OPTS | |
mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" | |
if [ -n "$MAX_OPEN_FILES" ]; then | |
ulimit -n $MAX_OPEN_FILES | |
fi | |
if [ -n "$MAX_LOCKED_MEMORY" ]; then | |
ulimit -l $MAX_LOCKED_MEMORY | |
fi | |
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then | |
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT | |
fi | |
BIN_PATH=$ES_HOME/bin/elasticsearch | |
BIN_OPTS="--default.config=$CONF_FILE --default.path.home=$ES_HOME --default.path.logs=$LOG_DIR --default.path.data=$DATA_DIR --default.path.work=$WORK_DIR --default.path.conf=$CONF_DIR" | |
start-stop-daemon --start --user "$ES_USER" -c "$ES_USER" --exec $BIN_PATH -- $BIN_OPTS | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment