deb: add systemd service config for upcoming Jessie
This change adds a systemd service configuration file, and adds systemd logic to installation and de-installation scripts. The upcoming Debian 8 "Jessie" release will use systemd. fixes #8943 Signed-off-by: Thilo Fromm <github@thilo-fromm.de>
This commit is contained in:
parent
344bbf2ced
commit
98d18c4bd9
5
pom.xml
5
pom.xml
|
@ -975,6 +975,11 @@
|
|||
<group>root</group>
|
||||
</mapper>
|
||||
</data>
|
||||
<data>
|
||||
<src>${project.basedir}/src/deb/systemd/elasticsearch.service</src>
|
||||
<dst>/usr/lib/systemd/system/elasticsearch.service</dst>
|
||||
<type>file</type>
|
||||
</data>
|
||||
<data>
|
||||
<src>${project.basedir}/config</src>
|
||||
<type>directory</type>
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
/etc/default/elasticsearch
|
||||
/etc/elasticsearch/logging.yml
|
||||
/etc/elasticsearch/elasticsearch.yml
|
||||
/usr/lib/systemd/system/elasticsearch.service
|
||||
|
|
|
@ -4,7 +4,10 @@ set -e
|
|||
[ -f /etc/default/elasticsearch ] && . /etc/default/elasticsearch
|
||||
|
||||
startElasticsearch() {
|
||||
if [ -x "/etc/init.d/elasticsearch" ]; then
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl daemon-reload
|
||||
/bin/systemctl start elasticsearch.service
|
||||
elif [ -x "/etc/init.d/elasticsearch" ]; then
|
||||
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
||||
invoke-rc.d elasticsearch start || true
|
||||
else
|
||||
|
@ -42,10 +45,19 @@ case "$1" in
|
|||
startElasticsearch
|
||||
# this is a fresh installation
|
||||
elif [ -z $2 ] ; then
|
||||
echo "### NOT starting elasticsearch by default on bootup, please execute"
|
||||
echo " sudo update-rc.d elasticsearch defaults 95 10"
|
||||
echo "### In order to start elasticsearch, execute"
|
||||
echo " sudo /etc/init.d/elasticsearch start"
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
echo "### NOT starting on installation, please execute the following statements to configure elasticsearch to start automatically using systemd"
|
||||
echo " sudo /bin/systemctl daemon-reload"
|
||||
echo " sudo /bin/systemctl enable elasticsearch.service"
|
||||
echo "### You can start elasticsearch by executing"
|
||||
echo " sudo /bin/systemctl start elasticsearch.service"
|
||||
|
||||
elif [ -x /usr/sbin/update-rc.d ] ; then
|
||||
echo "### NOT starting elasticsearch by default on bootup, please execute"
|
||||
echo " sudo update-rc.d elasticsearch defaults 95 10"
|
||||
echo "### In order to start elasticsearch, execute"
|
||||
echo " sudo /etc/init.d/elasticsearch start"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -5,14 +5,23 @@ case "$1" in
|
|||
remove)
|
||||
# Remove logs
|
||||
rm -rf /var/log/elasticsearch
|
||||
|
||||
|
||||
# disable elasticsearch service on systemd systems
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl --no-reload disable elasticsearch.service > /dev/null 2>&1 || :
|
||||
fi
|
||||
# remove **only** empty data dir
|
||||
rmdir --ignore-fail-on-non-empty /var/lib/elasticsearch
|
||||
;;
|
||||
|
||||
purge)
|
||||
# Remove service
|
||||
update-rc.d elasticsearch remove >/dev/null || true
|
||||
# disable elasticsearch service on systemd systems
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl --no-reload disable elasticsearch.service > /dev/null 2>&1 || :
|
||||
else
|
||||
update-rc.d elasticsearch remove >/dev/null || true
|
||||
fi
|
||||
|
||||
# Remove logs and data
|
||||
rm -rf /var/log/elasticsearch /var/lib/elasticsearch
|
||||
|
|
|
@ -4,7 +4,9 @@ set -e
|
|||
[ -f /etc/default/elasticsearch ] && . /etc/default/elasticsearch
|
||||
|
||||
stopElasticsearch() {
|
||||
if [ -x "/etc/init.d/elasticsearch" ]; then
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
/bin/systemctl --no-reload stop elasticsearch.service > /dev/null 2>&1 || :
|
||||
elif [ -x "/etc/init.d/elasticsearch" ]; then
|
||||
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
||||
invoke-rc.d elasticsearch stop || true
|
||||
else
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
[Unit]
|
||||
Description=Starts and stops a single elasticsearch instance on this system
|
||||
Documentation=http://www.elasticsearch.org
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/etc/default/elasticsearch
|
||||
User=elasticsearch
|
||||
Group=elasticsearch
|
||||
ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
|
||||
-Des.default.config=$CONF_FILE \
|
||||
-Des.default.path.home=$ES_HOME \
|
||||
-Des.default.path.logs=$LOG_DIR \
|
||||
-Des.default.path.data=$DATA_DIR \
|
||||
-Des.default.path.work=$WORK_DIR \
|
||||
-Des.default.path.conf=$CONF_DIR
|
||||
# See MAX_OPEN_FILES in sysconfig
|
||||
LimitNOFILE=65535
|
||||
# See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true
|
||||
#LimitMEMLOCK=infinity
|
||||
# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
|
||||
TimeoutStopSec=20
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue