Re: s6-log: Log rotation during shutdown
"Laurent Bercot" <[email protected]> Fri, 27 Feb 2026 21:46:55 +0000
| Newsgroups | gmane.comp.sysutils.supervision.general |
|---|---|
| Message-ID | <[email protected]> |
>I don't want to loose any logs on shutdown/reboot (let's ignore sudden >power loss), so the idea is to force log rotation by sending SIGALRM >and reboot device only if log export was Ok otherwise keep retrying, but >reboot eventually after some timeout. > >But, s6-log doesn't seem to wait for script to finish, so sending SIGALRM >and then SIGHUP doesn't work as I expected. > Also if I send SIGHUP >immediately after SIGALRM s6-log dies with: > >fatal: inconsistent state in logdir_finalize() Indeed there is no protection against a terminating signal (why are you using SIGHUP over SIGTERM by the way?) while a processor script is running, that's something that I probably should fix. I'll think about a way to do this for the next version of s6. In the meantime, you can tell your processor script to notify something right before it exits with success (e.g. via a fifodir), and synchronize your reboot script that way. For instance: once: s6-mkfifodir /var/run/foo-sync at the end of your processor script: s6-ftrig-notify /var/run/foo-sync "!" in your shutdown script: s6-ftrig-listen1 /var/run/foo-sync "!" s6-svc -a /run/service/foo/log \ && reboot -f Note that if your logdir is on a tmpfs, you don't even need to kill the logger before rebooting: as long as its producer has stopped writing and the processor script has done what you want, you're good to go. You don't have to fully complete the rotation and finalize the log file=20 since it's going to be wiped anyway. -- Laurent