unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@yhbt.net>
Subject: [PATCH 04/11] watch: log signal activities to STDERR
Date: Mon, 31 Aug 2020 04:41:33 +0000	[thread overview]
Message-ID: <20200831044140.17027-5-e@80x24.org> (raw)
In-Reply-To: <20200831044140.17027-1-e@80x24.org>

From: Eric Wong <e@yhbt.net>

Sometimes it may not be apparent when/if a signal is
processed, this hopefully improves the situation.

We'll also change the process title when we're quitting
to better inform users.
---
 script/public-inbox-watch | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index 02491860..b6c6b202 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -11,18 +11,30 @@ use PublicInbox::Syscall qw($SFD_NONBLOCK);
 my $oldset = PublicInbox::Sigfd::block_signals();
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
-my ($config, $watch);
+local $0 = $0; # local since this script may be eval-ed
+my $watch = PublicInbox::Watch->new(PublicInbox::Config->new);
 my $reload = sub {
-	$config = PublicInbox::Config->new;
-	$watch->quit if $watch;
-	$watch = PublicInbox::Watch->new($config);
+	my $prev = $watch or return; # SIGQUIT issued
+	$watch->quit;
+	$watch = PublicInbox::Watch->new(PublicInbox::Config->new);
+	if ($watch) {
+		warn("I: reloaded\n");
+	} else {
+		warn("E: reloading failed\n");
+		$watch = $prev;
+	}
 };
-$reload->();
+
 if ($watch) {
-	my $scan = sub { $watch->trigger_scan('full') if $watch };
+	my $scan = sub {
+		return if !$watch;
+		warn "I: scanning\n";
+		$watch->trigger_scan('full');
+	};
 	my $quit = sub {
 		$watch->quit if $watch;
 		$watch = undef;
+		$0 .= ' quitting';
 	};
 	my $sig = {
 		HUP => $reload,

  parent reply	other threads:[~2020-08-31  4:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  4:41 [PATCH 00/11] watch: fix contention w/ Maildir & NNTP Eric Wong
2020-08-31  4:41 ` [PATCH 01/11] watch: limit batch size of NNTP and IMAP workers, too Eric Wong
2020-08-31  4:41 ` [PATCH 02/11] watchmaildir: use v5.10.1, drop warnings Eric Wong
2020-08-31  4:41 ` [PATCH 03/11] rename WatchMaildir => Watch Eric Wong
2020-08-31  4:41 ` Eric Wong [this message]
2020-08-31  4:41 ` [PATCH 05/11] watch: avoid unnecessary spawning on spam removals Eric Wong
2020-08-31  4:41 ` [PATCH 06/11] watch: block signals before fork on non-signalfd/kevent systems Eric Wong
2020-08-31  4:41 ` [PATCH 07/11] watch: comments and tiny cleanups Eric Wong
2020-08-31  4:41 ` [PATCH 08/11] ds: avoid excessive queueing when reaping PIDs Eric Wong
2020-08-31  4:41 ` [PATCH 09/11] watch: use EOFpipe to reduce dwaitpid wakeups Eric Wong
2020-08-31  4:41 ` [PATCH 10/11] ds: avoid unnecessary timer for waitpid Eric Wong
2020-08-31  4:41 ` [PATCH 11/11] replace ParentPipe with EOFpipe Eric Wong

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://public-inbox.org/README

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

  git send-email \
    --in-reply-to=20200831044140.17027-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=e@yhbt.net \
    --cc=meta@public-inbox.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 read-only IMAP folder(s) and NNTP newsgroup(s).