-$reload->();
-if ($watch_md) {
- my $scan = sub { $watch_md->trigger_scan('full') if $watch_md };
- $SIG{HUP} = $reload;
- $SIG{USR1} = $scan;
- $SIG{ALRM} = sub { $SIG{ALRM} = 'DEFAULT'; $scan->() };
- alarm(1);
- $watch_md->watch while ($watch_md);
+
+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,
+ USR1 => $scan,
+ CHLD => \&PublicInbox::DS::enqueue_reap,
+ };
+ $sig->{QUIT} = $sig->{TERM} = $sig->{INT} = $quit;
+
+ # --no-scan is only intended for testing atm, undocumented.
+ PublicInbox::DS::requeue($scan) if $do_scan;
+ $watch->watch($sig, $oldset) while ($watch);