Bug 2371574 - Use `systemctl try-reload-or-restart` in logrotate postrotate script
Summary: Use `systemctl try-reload-or-restart` in logrotate postrotate script
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: icecast
Version: 42
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-06-10 19:00 UTC by Marcos Mello
Modified: 2025-06-21 02:10 UTC (History)
4 users (show)

Fixed In Version: icecast-2.4.4-24.fc43 icecast-2.4.4-24.fc42 icecast-2.4.4-19.fc41
Clone Of:
Environment:
Last Closed: 2025-06-21 01:25:59 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Marcos Mello 2025-06-10 19:00:04 UTC
`systemctl try-reload-or-restart` leverages systemd's knowledge of the daemon's main PID, eliminating the need to rely on PID files or external tools like `killall` or `pkill`. The action of icecast.service's `ExecReload=` sends the same signal as currently sent by `kill`, making it a suitable replacement. This ensures precise signal sending to the intended process, reducing the risk of errors in process identification. Additionally, `systemctl try-reload-or-restart` is silent by default and returns zero if the daemon is inactive. It also logs the action in the service's journal, providing a record of actions taken.

The logrotate configuration snippet:

# cat /etc/logrotate.d/icecast
/var/log/icecast/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/icecast/icecast.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

In the postrotate script, kill can be replaced by:

/usr/bin/systemctl try-reload-or-restart icecast.service

Because:

# systemctl show -P ExecReload icecast.service
{ path=/bin/kill ; argv[]=/bin/kill -HUP $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }

In addition to the fact that the PID file doesn't even exist, it wasn't working anyway:

# systemctl is-active icecast.service ; cat /var/run/icecast/icecast.pid
active
cat: /var/run/icecast/icecast.pid: No such file or directory

Reproducible: Always




Additional Information:
icecast-2.4.4-23.fc42.x86_64

Comment 1 Petr Pisar 2025-06-11 08:51:09 UTC
Thanks for the bug report. It's a good idea.

Comment 2 Fedora Update System 2025-06-11 10:52:06 UTC
FEDORA-2025-3ad202c6a1 (icecast-2.4.4-24.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-3ad202c6a1

Comment 3 Fedora Update System 2025-06-11 11:05:57 UTC
FEDORA-2025-e37b80b0f3 (icecast-2.4.4-19.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-e37b80b0f3

Comment 4 Marcos Mello 2025-06-11 11:21:40 UTC
Thank you. Cosmetic observation: `systemctl try-reload-or-restart` is silent by default and returns zero even when the daemon is inactive. It displays an error and returns non-zero when the unit file does not exist, which cannot happen, or when the `ExecReload=` command fails, whose error would be useful to indicate an issue with the unit file. Therefore, `1>/dev/null 2>/dev/null || true` at the end can be safely removed.

Comment 5 Fedora Update System 2025-06-12 02:58:54 UTC
FEDORA-2025-3ad202c6a1 has been pushed to the Fedora 42 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-3ad202c6a1`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-3ad202c6a1

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2025-06-12 03:57:10 UTC
FEDORA-2025-e37b80b0f3 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-e37b80b0f3`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-e37b80b0f3

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2025-06-21 01:25:59 UTC
FEDORA-2025-3ad202c6a1 (icecast-2.4.4-24.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2025-06-21 02:10:54 UTC
FEDORA-2025-e37b80b0f3 (icecast-2.4.4-19.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.