diff --git a/pkg/centos/after-install.sh b/pkg/centos/after-install.sh index 3c6f2405746..dbfe1c00fb5 100644 --- a/pkg/centos/after-install.sh +++ b/pkg/centos/after-install.sh @@ -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 diff --git a/pkg/debian/after-install.sh b/pkg/debian/after-install.sh index 51ea473b0ee..c0a1c37bbbd 100644 --- a/pkg/debian/after-install.sh +++ b/pkg/debian/after-install.sh @@ -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 diff --git a/pkg/ubuntu/after-install.sh b/pkg/ubuntu/after-install.sh index c1a22fe8382..bf26677d19a 100644 --- a/pkg/ubuntu/after-install.sh +++ b/pkg/ubuntu/after-install.sh @@ -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