Bug 2371317
| Summary: | Use `systemctl try-reload-or-restart` in logrotate postrotate script | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Marcos Mello <marcosfrm> |
| Component: | svxlink | Assignee: | Scott K Logan <logans> |
| Status: | NEW --- | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | low | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 42 | CC: | logans |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | --- | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
The same applies to svxlink:
# cat /etc/logrotate.d/svxlink-server
/var/log/svxlink {
missingok
notifempty
weekly
create 0644 svxlink daemon
postrotate
killall -HUP svxlink
endscript
}
In the postrotate script, killall can be replaced by:
/usr/bin/systemctl try-reload-or-restart svxlink.service
Because:
# systemctl show -P ExecReload svxlink.service
{ path=/bin/kill ; argv[]=/bin/kill -s HUP $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
# systemctl show -P MainPID svxlink.service
3418
# pgrep svxlink
3418
|
Use `systemctl try-reload-or-restart` in logrotate postrotate script `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 remotetrx.service's `ExecReload=` sends the same signal as currently sent by `killall`, 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/remotetrx /var/log/remotetrx { missingok notifempty weekly create 0644 svxlink daemon postrotate killall -HUP remotetrx endscript } In the postrotate script, killall can be replaced by: /usr/bin/systemctl try-reload-or-restart remotetrx.service Because: # systemctl show -P ExecReload remotetrx.service { path=/bin/kill ; argv[]=/bin/kill -s HUP $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } # systemctl show -P MainPID remotetrx.service 1748 # pgrep remotetrx 1748 Reproducible: Always Additional Information: svxlink-server-1.8.0-5.fc42.x86_64