Skip to content

Commit

Permalink
rpm: use more portable command
Browse files Browse the repository at this point in the history
systemctl show fluentd --property=MainPID returns MainPID=PID
but that option only available since systemd 230 or later.

In amazonlinux:2, the version of systemd is 219, so it is not
available.

Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
  • Loading branch information
kenhys committed Oct 23, 2024
1 parent 31a4348 commit 981cd89
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fluent-package/yum/fluent-package.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ if [ $1 -eq 1 ]; then
. %{_sysconfdir}/sysconfig/@SERVICE_NAME@
echo "postun FLUENT_PACKAGE_SERVICE_RESTART: $FLUENT_PACKAGE_SERVICE_RESTART"
if [ "$FLUENT_PACKAGE_SERVICE_RESTART" = "auto" ]; then
pid=$(systemctl show fluentd --property=MainPID --value)
# systemctl ... --property=MainPID --value is available since systemd 230 or later.
# thus for amazonlinux:2, it can not be used.
pid=$(systemctl show fluentd --property=MainPID | cut -d'=' -f2)
if [ $pid -gt 0 ]; then
echo "Kick auto service upgrade mode to MainPID:$pid"
kill -USR2 $pid
Expand Down

0 comments on commit 981cd89

Please sign in to comment.