mirror of
https://github.com/elastic/logstash.git
synced 2025-04-19 04:15:23 -04:00
Fix system unit TimeoutStopSec on older version. (#14947)
Fixes the system unit TimeoutStopSec option to set 0 on older version that do not support 'infinity'. Also handles the upgrade case where the OS may not automatically upgrade the systemd file.
This commit is contained in:
parent
311d4dc30e
commit
a1166cc9ba
3 changed files with 51 additions and 0 deletions
|
@ -7,5 +7,23 @@ sed -i \
|
|||
/etc/logstash/logstash.yml
|
||||
chmod 600 /etc/logstash/startup.options
|
||||
chmod 600 /etc/default/logstash
|
||||
|
||||
# Starting from systemd 229, TimeouStopSec supports using
|
||||
# 'infinity' to disable not send a SIG Kill.
|
||||
#
|
||||
# Older versions need to use 0 instead.
|
||||
systemd_version=$(rpm -q systemd 2> /dev/null | cut -d '-' -f2)
|
||||
if [ -n $systemd_version ] && [ $systemd_version -lt 229 ]; then
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=infinity/TimeoutStopSec=0/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
else
|
||||
# Ensure's an upgraded system has the right setting, if it
|
||||
# wasn't automatically replaced by the OS.
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=0/TimeoutStopSec=infinity/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
fi
|
||||
|
||||
# Ensure the init script is picked up by systemd
|
||||
systemctl daemon-reload 2> /dev/null || true
|
||||
|
|
|
@ -11,3 +11,19 @@ sed -i \
|
|||
chmod 600 /etc/logstash/startup.options
|
||||
chmod 600 /etc/default/logstash
|
||||
|
||||
# Starting from systemd 229, TimeouStopSec supports using
|
||||
# 'infinity' to disable not send a SIG Kill.
|
||||
#
|
||||
# Older versions need to use 0 instead.
|
||||
systemd_version=$(dpkg-query --showformat='${Version}' --show systemd 2> /dev/null)
|
||||
if [ -n $systemd_version ] && dpkg --compare-versions "$systemd_version" lt 229 ; then
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=infinity/TimeoutStopSec=0/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
else
|
||||
# Ensure's an upgraded system has the right setting, if it
|
||||
# wasn't automatically replaced by the OS.
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=0/TimeoutStopSec=infinity/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
fi
|
||||
|
|
|
@ -9,3 +9,20 @@ sed -i \
|
|||
/etc/logstash/logstash.yml
|
||||
chmod 600 /etc/logstash/startup.options
|
||||
chmod 600 /etc/default/logstash
|
||||
|
||||
# Starting from systemd 229, TimeouStopSec supports using
|
||||
# 'infinity' to disable not send a SIG Kill.
|
||||
#
|
||||
# Older versions need to use 0 instead.
|
||||
systemd_version=$(dpkg-query --showformat='${Version}' --show systemd 2> /dev/null)
|
||||
if [ -n $systemd_version ] && dpkg --compare-versions "$systemd_version" lt 229 ; then
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=infinity/TimeoutStopSec=0/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
else
|
||||
# Ensure's an upgraded system has the right setting, if it
|
||||
# wasn't automatically replaced by the OS.
|
||||
sed -i \
|
||||
-e "s/^TimeoutStopSec=0/TimeoutStopSec=infinity/" \
|
||||
/lib/systemd/system/logstash.service || true
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue