summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-misc/elasticsearch/files')
-rw-r--r--app-misc/elasticsearch/files/elasticsearch-env.patch24
-rw-r--r--app-misc/elasticsearch/files/elasticsearch.conf.362
-rw-r--r--app-misc/elasticsearch/files/elasticsearch.init.669
-rw-r--r--app-misc/elasticsearch/files/elasticsearch.init.9 (renamed from app-misc/elasticsearch/files/elasticsearch.init.7)8
-rw-r--r--app-misc/elasticsearch/files/elasticsearch.service.467
5 files changed, 95 insertions, 135 deletions
diff --git a/app-misc/elasticsearch/files/elasticsearch-env.patch b/app-misc/elasticsearch/files/elasticsearch-env.patch
new file mode 100644
index 000000000000..fb150bb51db3
--- /dev/null
+++ b/app-misc/elasticsearch/files/elasticsearch-env.patch
@@ -0,0 +1,24 @@
+Since ES 8.0.0 upstream stopped distributing a 'no-JDK' package.
+This requires us to set `ES_JAVA_HOME` else it fails to find the
+JDK that we unbundled and will not start.
+--- a/bin/elasticsearch-env
++++ b/bin/elasticsearch-env
+@@ -36,6 +36,18 @@ ES_HOME=`dirname "$ES_HOME"`
+ ES_CLASSPATH="$ES_HOME/lib/*"
+ LAUNCHERS_CLASSPATH="$ES_CLASSPATH:$ES_HOME/lib/launchers/*"
+
++# Set our JVM in a Gentoo-specific manner
++if [ -z "$ES_JAVA_HOME" ]; then
++ GENTOO_VM=$(depend-java-query --get-vm virtual/jre:17)
++ if [ ! -z "$GENTOO_VM" ]; then
++ ES_JAVA_HOME=$(java-config-2 --select-vm=${GENTOO_VM} --jre-home)
++ else
++ echo "Unable to automatically detect a supported Java 17 VM. Elasticsearch is unlikely to launch."
++ echo "Please ensure that you have installed an appropriate Java VM using portage"
++ echo "OR pass the ES_JAVA_HOME environment variable."
++ fi
++fi
++
+ # now set the path to java
+ if [ ! -z "$ES_JAVA_HOME" ]; then
+ JAVA="$ES_JAVA_HOME/bin/java"
diff --git a/app-misc/elasticsearch/files/elasticsearch.conf.3 b/app-misc/elasticsearch/files/elasticsearch.conf.3
deleted file mode 100644
index 70c052a64cce..000000000000
--- a/app-misc/elasticsearch/files/elasticsearch.conf.3
+++ /dev/null
@@ -1,62 +0,0 @@
-################################
-# Elasticsearch
-################################
-
-# Elasticsearch home directory
-#ES_HOME=/usr/share/elasticsearch
-
-# Elasticsearch Java path
-#JAVA_HOME=
-
-# Elasticsearch configuration directory
-#CONF_DIR=/etc/elasticsearch
-
-# Elasticsearch data directory
-#DATA_DIR=/var/lib/elasticsearch
-
-# Elasticsearch logs directory
-#LOG_DIR=/var/log/elasticsearch
-
-# Additional Java OPTS
-#ES_JAVA_OPTS=
-
-################################
-# 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=65536
-
-# The maximum number of bytes of memory that may be locked into RAM
-# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
-# in elasticsearch.yml.
-# 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
-
-# https://www.elastic.co/guide/en/elasticsearch/reference/master/max-number-of-threads.html
-MAX_THREADS=4096
-
-rc_ulimit="-l $MAX_LOCKED_MEMORY -n $MAX_OPEN_FILES -u $MAX_THREADS"
diff --git a/app-misc/elasticsearch/files/elasticsearch.init.6 b/app-misc/elasticsearch/files/elasticsearch.init.6
deleted file mode 100644
index 046941d407e5..000000000000
--- a/app-misc/elasticsearch/files/elasticsearch.init.6
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/sbin/openrc-run
-
-name="Elasticsearch"
-description="Elasticsearch Server"
-
-ES_INSTANCE=${RC_SVCNAME#*.}
-
-if [ -n "${ES_INSTANCE}" ] && [ ${RC_SVCNAME} != "elasticsearch" ]; then
- ES_BASE_PATH="/var/lib/elasticsearch/${ES_INSTANCE}"
- CONF_DIR="/etc/elasticsearch/${ES_INSTANCE}"
- DEFAULT_LOG_DIR="/var/log/elasticsearch/${ES_INSTANCE}"
-else
- ES_BASE_PATH="/var/lib/elasticsearch/_default"
- CONF_DIR="/etc/elasticsearch"
- DEFAULT_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_STARTUP_SLEEP_TIME=${ES_STARTUP_TIME:=5}
-JAVA_HOME=${JAVA_HOME:=$(java-config -g JAVA_HOME)}
-MAX_OPEN_FILES=${MAX_OPEN_FILES:=65536}
-MAX_MAP_COUNT=${MAX_MAP_COUNT:=262144}
-
-DATA_DIR=${DATA_DIR:="${ES_BASE_PATH}/data"}
-LOG_DIR=${LOG_DIR:="${DEFAULT_LOG_DIR}"}
-
-if [ -f "${CONF_DIR}/elasticsearch.in.sh" ]; then
- ES_INCLUDE="${CONF_DIR}/elasticsearch.in.sh"
-fi
-
-export ES_INCLUDE
-export JAVA_HOME
-export JAVA_OPTS
-export ES_JVM_OPTIONS
-export ES_JAVA_OPTS
-export ES_STARTUP_SLEEP_TIME
-export ES_PATH_CONF="${CONF_DIR}"
-
-pidfile="/run/elasticsearch/${RC_SVCNAME}.pid"
-
-command="/usr/share/elasticsearch/bin/elasticsearch"
-command_args="-Epath.logs=${LOG_DIR} -Epath.data=${DATA_DIR}"
-command_args_background="--daemonize --pidfile=${pidfile}"
-command_user="${ES_USER}:${ES_GROUP}"
-required_files="${CONF_DIR}/elasticsearch.yml"
-retry="TERM/30/KILL/30"
-
-depend() {
- use net
-}
-
-start_pre() {
- 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
-
- 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 "/run/elasticsearch"
- checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${ES_BASE_PATH}"
- checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${LOG_DIR}"
-
- # fails to start without keystore
- if [ ! -f "${CONF_DIR}/elasticsearch.keystore" ]; then
- "${ES_HOME}/bin/elasticsearch-keystore" create
- fi
-}
diff --git a/app-misc/elasticsearch/files/elasticsearch.init.7 b/app-misc/elasticsearch/files/elasticsearch.init.9
index cac781c968d1..5e4f2a70f41d 100644
--- a/app-misc/elasticsearch/files/elasticsearch.init.7
+++ b/app-misc/elasticsearch/files/elasticsearch.init.9
@@ -19,7 +19,7 @@ ES_HOME=${ES_HOME:="/usr/share/elasticsearch"}
ES_USER=${ES_USER:="elasticsearch"}
ES_GROUP=${ES_GROUP:="elasticsearch"}
ES_STARTUP_SLEEP_TIME=${ES_STARTUP_TIME:=5}
-JAVA_HOME=${JAVA_HOME:=$(java-config -g JAVA_HOME)}
+ES_JAVA_HOME=${ES_JAVA_HOME:=$(java-config -g JAVA_HOME)}
MAX_OPEN_FILES=${MAX_OPEN_FILES:=65536}
MAX_MAP_COUNT=${MAX_MAP_COUNT:=262144}
@@ -31,10 +31,9 @@ if [ -f "${CONF_DIR}/elasticsearch.in.sh" ]; then
fi
export ES_INCLUDE
-export JAVA_HOME
-export JAVA_OPTS
-export ES_JVM_OPTIONS
+export ES_JAVA_HOME
export ES_JAVA_OPTS
+export ES_JVM_OPTIONS
export ES_STARTUP_SLEEP_TIME
export ES_PATH_CONF="${CONF_DIR}"
@@ -59,6 +58,7 @@ start_pre() {
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 "/run/elasticsearch"
+ checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${ES_HOME}/plugins"
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${ES_BASE_PATH}"
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${LOG_DIR}"
diff --git a/app-misc/elasticsearch/files/elasticsearch.service.4 b/app-misc/elasticsearch/files/elasticsearch.service.4
new file mode 100644
index 000000000000..6c5b256706c9
--- /dev/null
+++ b/app-misc/elasticsearch/files/elasticsearch.service.4
@@ -0,0 +1,67 @@
+[Unit]
+Description=Elasticsearch
+Documentation=https://www.elastic.co
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Type=simple
+RuntimeDirectory=elasticsearch
+PrivateTmp=true
+Environment=ES_HOME=/usr/share/elasticsearch
+Environment=ES_PATH_CONF=/etc/elasticsearch
+
+WorkingDirectory=/usr/share/elasticsearch
+
+ExecStartPre=+"/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec"
+
+User=elasticsearch
+Group=elasticsearch
+
+ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
+ -p ${PID_DIR}/elasticsearch.pid \
+ -Epath.logs=${LOG_DIR} \
+ -Epath.data=${DATA_DIR} \
+ --quiet
+
+# StandardOutput is configured to redirect to journalctl since
+# some error messages may be logged in standard output before
+# elasticsearch logging system is initialized. Elasticsearch
+# stores its logs in /var/log/elasticsearch and does not use
+# journalctl by default. If you also want to enable journalctl
+# logging, you can simply remove the "quiet" option from ExecStart.
+StandardOutput=journal
+StandardError=inherit
+
+# Specifies the maximum file descriptor number that can be opened by this process
+LimitNOFILE=65535
+
+# Specifies the maximum number of processes
+LimitNPROC=4096
+
+# Specifies the maximum size of virtual memory
+LimitAS=infinity
+
+# Specifies the maximum file size
+LimitFSIZE=infinity
+
+# Disable timeout logic and wait until process is stopped
+TimeoutStopSec=0
+
+# SIGTERM signal is used to stop the Java process
+KillSignal=SIGTERM
+
+# Send the signal only to the JVM rather than its control group
+KillMode=process
+
+# Java process is never killed
+SendSIGKILL=no
+
+# When a JVM receives a SIGTERM signal it exits with code 143
+SuccessExitStatus=143
+
+# Allow a slow startup before the systemd notifier module kicks in to extend the timeout
+TimeoutStartSec=75
+
+[Install]
+WantedBy=multi-user.target