README: packages, link to man page, contributing
*poof*
Rolf Re-Opens Log Files.
Rolf is a highly-specific, single-purpose tool. It redirects another program's output to logfiles, and will re-open these logfiles on SIGHUP. This makes it play nice with standard log-rotation tools.
rolf [-l|--logfile=FILE] [-o|--stdout=FILE] [-e|--stderr=FILE] -- CMD [ARGS...]
Rolf will execute CMD [ARGS...]
as child process and capture its stdout and
stderr. It will redirect them either to a single file (-l
) or individual
files (-o
and/or -e
).
Upon receiving SIGHUP, rolf re-opens all logfiles. Upon receiving SIGINT, SIGUSR1, or SIGUSR2, rolf will relay the respective signal to the child process. If the child process exits normally, rolf will exit with the same exit code as the child process. If the child exits abnormally (i.e. without exit code), rolf will exit with exit code -1.
The man page has more details.
Many process supervisors support some sort of log capturing facilities for
services that only write to stdout/stderr. Some of those integrate log rotation
(for example journald
for systemd
, or svlogd
for runsv
).
OpenRC's supervise-daemon
supports the redirection of stdout/stderr, but no
log rotation. And since it never re-opens its logfile(s), using a standard log
rotation tool involves whacky work-arounds.
Rolf is meant to help with that. Simply have supervise-daemon
run your
service using rolf as proxy. You can then re-open logfiles by running
supervise-daemon <SERVICE> -s SIGHUP
.
The man page has as example OpenRC service to illustrate this.
Alpine packages are available:
curl -o /etc/apk/keys/conrad-6297636d.rsa.pub https://apk.bitfehler.net/conrad-6297636d.rsa.pub
echo "https://apk.bitfehler.net/v3.19/apk" >> /etc/apk/repositories
apk update && apk add rolf
Note: also available for 3.18, simply adjust the URL.
This project has no dedicated mailing list at this time. You can send questions, comments, or patches to my public inbox. If you don't like sending patches by email, feel free to create a fork on Github/Gitlab/Codeberg/... and send my a link.
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Conrad Hoffmann ch@bitfehler.net