unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Felix Lechner via "Development of GNU Guix and the GNU System distribution." <guix-devel@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>, guix-devel@gnu.org
Subject: Re: Shepherd log rotation service
Date: Wed, 22 May 2024 10:54:23 -0700	[thread overview]
Message-ID: <877cflu3zk.fsf@lease-up.com> (raw)
In-Reply-To: <87ed9y4ygj.fsf@inria.fr>


Hi Ludo',

> I’ve just pushed a simple log rotation service for Shepherd:

Wow, that's another cool addition!  I am currently testing a patch that
removes the rottlog service extension from all services that use
#:log-file.  Not all do.

I should will make an immediate dent in my 200 MB log file for Fcgiwrap,
but not for an Rspamd file of similar size.  Also, my Nginx log file
with 1.3 GB will remain unaffected.  Most significantly, it simplifies a
lot of code.

To make the addition of my new log-rotation-service-type compatible with
folks who use the rottlog service extension outside the main repo, I
also hope to make the service extension a no-op when the underlying
Shepherd service uses the #:log-file facility.

Meanwhile, I have a few questions:

Should log-rotation-service be called make-log-rotation-service?

Should the key #:rotation-size-threshold be renamed to size-threshold?
I'm not asking to change the name of the variable holding the default
value.  The current key looks longer than needed in this code:

(define (log-rotation-shepherd-service config)
  (match-record
      config <log-rotation-configuration> (compression
                                           event
                                           expiry
                                           size-threshold)
    #~((log-rotation-service #$event
                             #:compression #$compression
                             #:expiry #$expiry
                             #:rotation-size-threshold #$size-threshold))))

Also, is it good practice, in log-rotation-service, to use an optional
argument (for event) together with keyword arguments?  Why not use
keyword arguments all around?

Finally, are there truly no (Shepherd) service requirements?  Or will
any Shepherd service that uses #:log-file automatically make sure that
the file-system is available?

Thank you for this cool new feature!

Kind regards
Felix




On Sat, May 18 2024, Ludovic Courtès wrote:

> Hello Guix!
>
>
>   https://git.savannah.gnu.org/cgit/shepherd.git/commit/?h=devel&id=0484726801c2b5c1b7deecb9a96054c2c510ac71
>
> It rotates log files roughly the same way we’ve been doing since the
> 70’s, but there’s a couple of advantages compared to what we’re
> currently doing in Guix System:
>
>   • No need to repeat the name of log files since shepherd already knows
>     them via #:log-file (that’s another reason to avoid
>     non-shepherd-managed log files).
>
>   • Rotation is race-free: it’s impossible to lose a line of log while
>     the file is being rotated.  This is guaranteed by the “logger”,
>     which offers a method to atomically close its log file, rename it,
>     and open a new empty log file.
>
>   • The log rotation service is a timer so one can inspect it with ‘herd
>     status log-rotation’, trigger it with ‘herd trigger log-rotation’,
>     and so on.
>
> At this point the log file of shepherd itself, for instance
> /var/log/messages, is not handled; this will have to be fixed.
>
> There aren’t many options to specify how to rotate logs (very few
> compared to rottlog!), but I figured we’d rather have something simple
> that works well and without surprises; we can always add knobs later if
> necessary.
>
> Feedback welcome!
>
> Ludo’.


  reply	other threads:[~2024-05-22 17:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-18 21:11 Shepherd log rotation service Ludovic Courtès
2024-05-22 17:54 ` Felix Lechner via Development of GNU Guix and the GNU System distribution. [this message]
2024-06-01 13:35   ` Ludovic Courtès
2024-05-23 14:20 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2024-06-01 13:30   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cflu3zk.fsf@lease-up.com \
    --to=guix-devel@gnu.org \
    --cc=felix.lechner@lease-up.com \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).