supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Andrew Stiegmann <andrew.stiegmann@gmail.com>
To: supervision@list.skarnet.org
Subject: Prevent runit from deleting own processing file
Date: Wed, 27 Mar 2024 17:15:54 -0800	[thread overview]
Message-ID: <CAEAwAmxgE_Uj8bknr8+aT47rz8bOP7x8hYd70EUaRn5Op6q-Xg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

Evening folks.  Wanted to share a patch I recently put together to prevent
a runaway busyloop in svlogd when system time is far behind.  It
effectively prevents svlogd from deleting the file its about to process,
which can happen when system time is far behind.  Cheers.

diff --git a/src/svlogd.c b/src/svlogd.c
index 2e79219..d47fc47 100644
--- a/src/svlogd.c
+++ b/src/svlogd.c
@@ -256,6 +256,10 @@ void rmoldest(struct logdir *ld) {
         if (unlink(f->d_name) == -1)
           warn2("unable to unlink processor leftover", f->d_name);
       }
+      else if (!str_diff(ld->fnsave, f->d_name)) {
+        if (verbose)
+          strerr_warn5(INFO, "preserve: ", ld->name, "/", ld->fnsave, 0);
+      }
       else {
         ++n;
         if (str_diff(f->d_name, oldest) < 0) byte_copy(oldest, 27,
f->d_name);

-- 
Andrew AV. Stiegmann

             reply	other threads:[~2024-03-28  1:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  1:15 Andrew Stiegmann [this message]
2024-03-28  2:26 ` Alexis
2024-03-28  3:27   ` Andrew Stiegmann

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

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

  git send-email \
    --in-reply-to=CAEAwAmxgE_Uj8bknr8+aT47rz8bOP7x8hYd70EUaRn5Op6q-Xg@mail.gmail.com \
    --to=andrew.stiegmann@gmail.com \
    --cc=supervision@list.skarnet.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.
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 NNTP newsgroup(s).