diff options
author | 2016-05-06 12:50:02 +0200 | |
---|---|---|
committer | 2016-05-06 12:50:56 +0200 | |
commit | 21dc3e1a5708d888c4d5fefdf124b03a309d5db0 (patch) | |
tree | 6685329ba20730968ef08cf31ed411afa1b76f46 /app-misc/elasticsearch/files | |
parent | sci-mathematics/cgal: Remove old (diff) | |
download | gentoo-21dc3e1a5708d888c4d5fefdf124b03a309d5db0.tar.gz gentoo-21dc3e1a5708d888c4d5fefdf124b03a309d5db0.tar.bz2 gentoo-21dc3e1a5708d888c4d5fefdf124b03a309d5db0.zip |
app-misc/elasticsearch: Bump
Fix #569116
New init script and systemd unit, closer to upstream
Small bugfixes etc.
Thanks to Ferenc Erki for preparing and testing
Package-Manager: portage-2.2.28
Diffstat (limited to 'app-misc/elasticsearch/files')
4 files changed, 229 insertions, 0 deletions
diff --git a/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec b/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec new file mode 100755 index 000000000000..a51d639bf7d4 --- /dev/null +++ b/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec @@ -0,0 +1,7 @@ +#!/bin/sh + +# CONF_FILE setting was removed +if [ ! -z "$CONF_FILE" ]; then + echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed." + exit 1 +fi diff --git a/app-misc/elasticsearch/files/elasticsearch.conf2 b/app-misc/elasticsearch/files/elasticsearch.conf2 new file mode 100644 index 000000000000..053cd18d1471 --- /dev/null +++ b/app-misc/elasticsearch/files/elasticsearch.conf2 @@ -0,0 +1,67 @@ +################################ +# Elasticsearch +################################ + +# Elasticsearch configuration directory +#CONF_DIR=/etc/elasticsearch + +# Elasticsearch data directory +#DATA_DIR=/var/lib/elasticsearch + +# Elasticsearch logs directory +#LOG_DIR=/var/log/elasticsearch + +# Elasticsearch PID directory +#PID_DIR=/run/elasticsearch + +# Heap size defaults to 256m min, 1g max +# Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g +#ES_HEAP_SIZE=2g + +# Heap new generation +#ES_HEAP_NEWSIZE= + +# Maximum direct memory +#ES_DIRECT_SIZE= + +# Additional Java OPTS +#ES_JAVA_OPTS= + +# Path to the GC log file +#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log + +################################ +# Elasticsearch service +################################ + +# When executing the init script, this user will be used to run the elasticsearch service. +# The default value is 'elasticsearch' and is declared in the init.d file. +# Note that this setting is only used by the init script. If changed, make sure that +# the configured user can read and write into the data, work, plugins and log directories. +# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service +#ES_USER=elasticsearch +#ES_GROUP=elasticsearch + +# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process +#ES_STARTUP_SLEEP_TIME=5 + +################################ +# System properties +################################ + +# Specifies the maximum file descriptor number that can be opened by this process +# When using Systemd, this setting is ignored and the LimitNOFILE defined in +# /usr/lib/systemd/system/elasticsearch.service takes precedence +#MAX_OPEN_FILES=65535 + +# The maximum number of bytes of memory that may be locked into RAM +# Set to "unlimited" if you use the 'bootstrap.mlockall: true' option +# in elasticsearch.yml (ES_HEAP_SIZE must also be set). +# When using Systemd, the LimitMEMLOCK property must be set +# in /usr/lib/systemd/system/elasticsearch.service +#MAX_LOCKED_MEMORY=unlimited + +# Maximum number of VMA (Virtual Memory Areas) a process can own +# When using Systemd, this setting is ignored and the 'vm.max_map_count' +# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf +#MAX_MAP_COUNT=262144 diff --git a/app-misc/elasticsearch/files/elasticsearch.init6 b/app-misc/elasticsearch/files/elasticsearch.init6 new file mode 100644 index 000000000000..9225f4893f8e --- /dev/null +++ b/app-misc/elasticsearch/files/elasticsearch.init6 @@ -0,0 +1,102 @@ +#!/sbin/runscript + +name="Elasticsearch" +description="Elasticsearch Server" + +ES_INSTANCE=${SVCNAME#*.} +PID_DIR=${PID_DIR:="/run/elasticsearch"} + +if [ -n "${ES_INSTANCE}" ] && [ ${SVCNAME} != "elasticsearch" ]; then + PIDFILE="${PID_DIR}/elasticsearch.${ES_INSTANCE}.pid" + ES_BASE_PATH="/var/lib/elasticsearch/${ES_INSTANCE}" + CONF_DIR="/etc/elasticsearch/${ES_INSTANCE}" + LOG_DIR="/var/log/elasticsearch/${ES_INSTANCE}" +else + PIDFILE="${PID_DIR}/elasticsearch.pid" + ES_BASE_PATH="/var/lib/elasticsearch/_default" + CONF_DIR="/etc/elasticsearch" + LOG_DIR="/var/log/elasticsearch/_default" +fi + +ES_HOME=${ES_HOME:="/usr/share/elasticsearch"} +ES_USER=${ES_USER:="elasticsearch"} +ES_GROUP=${ES_GROUP:="elasticsearch"} +ES_GC_LOG_FILE=${ES_GC_LOG_FILE:="${LOG_DIR}/gc.log"} +MAX_OPEN_FILES=${MAX_OPEN_FILES:=65535} +MAX_MAP_COUNT=${MAX_MAP_COUNT:=262144} + +DATA_DIR="${ES_BASE_PATH}/data" + +if [ -f "${CONF_DIR}/elasticsearch.in.sh" ]; then + ES_INCLUDE="${CONF_DIR}/elasticsearch.in.sh" +fi + +export ES_INCLUDE +export JAVA_OPTS +export ES_JAVA_OPTS +export ES_HEAP_SIZE +export ES_HEAP_NEWSIZE +export ES_DIRECT_SIZE +export ES_GC_LOG_FILE +export ES_STARTUP_SLEEP_TIME + +server_command="/usr/share/elasticsearch/bin/elasticsearch" +server_args="-d -p ${PIDFILE} --default.path.home=${ES_HOME} --default.path.logs=${LOG_DIR} --default.path.data=${DATA_DIR} --default.path.conf=${CONF_DIR}" + +depend() { + use net +} + +start() { + local conf + local conf_file + for conf in elasticsearch.yml logging.yml; do + conf_file="${CONF_DIR}/${conf}" + if [ ! -f "${conf_file}" ]; then + eerror "${conf_file} must be copied into place" + return 1 + fi + done + + if [ -n "${MAX_LOCKED_MEMORY}" -a -z "${ES_HEAP_SIZE}" ]; then + eerror "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" + return 1 + 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 + + ebegin "Starting ${SVCNAME}" + + if [ -n "${MAX_LOCKED_MEMORY}" ]; then + rc_ulimit="${rc_ulimit} -l ${MAX_LOCKED_MEMORY}" + fi + + if [ -n "${MAX_OPEN_FILES}" ]; then + rc_ulimit="${rc_ulimit} -n ${MAX_OPEN_FILES}" + fi + + checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "/var/lib/elasticsearch" + checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "/var/log/elasticsearch" + checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${PID_DIR}" + checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${ES_BASE_PATH}" + checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${LOG_DIR}" + + start-stop-daemon --start \ + --background \ + --chdir "${ES_HOME}" \ + --user="${ES_USER}" \ + --pidfile="${PIDFILE}" \ + --exec ${server_command} -- ${server_args} + eend $? +} + +stop() { + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop \ + --pidfile=${PIDFILE} \ + --user="${ES_USER}" \ + --retry=TERM/20 + eend $? +} diff --git a/app-misc/elasticsearch/files/elasticsearch.service5 b/app-misc/elasticsearch/files/elasticsearch.service5 new file mode 100644 index 000000000000..80ece6480f10 --- /dev/null +++ b/app-misc/elasticsearch/files/elasticsearch.service5 @@ -0,0 +1,53 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network.target +After=network.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/run/elasticsearch +EnvironmentFile=-/etc/conf.d/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -Des.pidfile=${PID_DIR}/elasticsearch.pid \ + -Des.default.path.home=${ES_HOME} \ + -Des.default.path.logs=${LOG_DIR} \ + -Des.default.path.data=${DATA_DIR} \ + -Des.default.path.conf=${CONF_DIR} + +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65535 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.mlockall: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/conf.d/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target |