2 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 usage: public-inbox-watch
7 See public-inbox-watch(1) man page for full documentation.
11 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
12 use IO::Handle; # ->autoflush
13 use PublicInbox::Watch;
14 use PublicInbox::Config;
17 GetOptions('scan!' => \$do_scan, # undocumented, testing only
18 'help|h' => \(my $show_help)) or do { print STDERR $help; exit 1 };
19 if ($show_help) { print $help; exit 0 };
20 my $oldset = PublicInbox::DS::block_signals();
23 local $0 = $0; # local since this script may be eval-ed
24 my $watch = PublicInbox::Watch->new(PublicInbox::Config->new);
26 my $prev = $watch or return; # SIGQUIT issued
28 $watch = PublicInbox::Watch->new(PublicInbox::Config->new);
30 warn("I: reloaded\n");
32 warn("E: reloading failed\n");
41 $watch->trigger_scan('full');
44 $watch->quit if $watch;
51 CHLD => \&PublicInbox::DS::enqueue_reap,
53 $sig->{QUIT} = $sig->{TERM} = $sig->{INT} = $quit;
55 # --no-scan is only intended for testing atm, undocumented.
56 PublicInbox::DS::requeue($scan) if $do_scan;
57 $watch->watch($sig, $oldset) while ($watch);