From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 652631FA11; Mon, 31 Aug 2020 04:41:41 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Cc: Eric Wong Subject: [PATCH 04/11] watch: log signal activities to STDERR Date: Mon, 31 Aug 2020 04:41:33 +0000 Message-Id: <20200831044140.17027-5-e@80x24.org> In-Reply-To: <20200831044140.17027-1-e@80x24.org> References: <20200831044140.17027-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Eric Wong 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,