X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=d0905562f6161946a8ce5c7bf09408853316d692;hb=4b5a1b5787edee2a3b6cc10a3ccc5721f1414268;hp=635cd0c5508aa3050640b3c2b001b5e8faf992e9;hpb=eb0e4dd09d540eb29c71fe1cc92161a13a0b608a;p=public-inbox.git diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 635cd0c5..d0905562 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -148,7 +148,7 @@ sub index_opt { my @c_opt = qw(c=s@ C=s@ quiet|q); my @net_opt = (qw(no-torsocks torsocks=s), PublicInbox::LeiQuery::curl_opt()); -my @lxs_opt = qw(remote! local! external! include|I=s@ exclude=s@ only=s@ +my @lxs_opt = qw(remote! local! external! include|I=s@ exclude=s@ only|O=s@ import-remote!); # we don't support -C as an alias for --find-copies since it's already @@ -284,7 +284,7 @@ our %CMD = ( # sorted in order of importance/use: }, qw(config-file|system|global|file|f=s), # for conflict detection qw(edit|e c=s@ C=s@), pass_through('git config') ], 'inspect' => [ 'ITEMS...|--stdin', 'inspect lei/store and/or local external', - qw(stdin| pretty ascii dir=s), @c_opt ], + qw(stdin| pretty ascii dir|d=s), @c_opt ], 'init' => [ '[DIRNAME]', sub { "initialize storage, default: ".store_path($_[0]); @@ -337,7 +337,8 @@ my %OPTDESC = ( 'path-a|a=s' => 'pre-image pathname associated with OID', 'path-b|b=s' => 'post-image pathname associated with OID', 'git-dir=s@' => 'additional git repository to scan', -'dir=s inspect' => 'specify a inboxdir, extindex topdir or Xapian shard', +'dir|d=s inspect' => + 'specify a inboxdir, extindex topdir or Xapian shard', 'proxy=s' => [ 'PROTO://HOST[:PORT]', # shared with curl(1) "proxy for (e.g. `socks5h://0:9050')" ], 'torsocks=s' => ['VAL|auto|no|yes', @@ -395,7 +396,7 @@ my %OPTDESC = ( 'exclude specified external(s) from search' ], 'include|I=s@ q' => [ 'LOCATION', 'include specified external(s) in search' ], -'only=s@ q' => [ 'LOCATION', +'only|O=s@ q' => [ 'LOCATION', 'only use specified external(s) for search' ], 'jobs=s q' => [ '[SEARCH_JOBS][,WRITER_JOBS]', 'control number of search and writer jobs' ], @@ -459,9 +460,9 @@ my @WQ_KEYS = qw(lxs l2m ikw pmd wq1 lne); # internal workers sub _drop_wq { my ($self) = @_; for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) { - if ($wq->wq_kill) { + if ($wq->wq_kill('-TERM')) { $wq->wq_close(0, undef, $self); - } elsif ($wq->wq_kill_old) { + } elsif ($wq->wq_kill_old('-TERM')) { $wq->wq_wait_old(undef, $self); } $wq->DESTROY; @@ -515,12 +516,6 @@ sub sigpipe_handler { # handles SIGPIPE from @WQ_KEYS workers fail_handler($_[0], 13, delete $_[0]->{1}); } -# PublicInbox::OnDestroy callback for SIGINT to take out the entire pgid -sub sigint_reap { - my ($pgid) = @_; - dwaitpid($pgid) if kill('-INT', $pgid); -} - sub fail ($$;$) { my ($self, $buf, $exit_code) = @_; local $current_lei = $self; @@ -575,6 +570,7 @@ sub _lei_atfork_child { } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly open STDERR, '+>&='.fileno($self->{2}) or warn "open $!"; STDERR->autoflush(1); + POSIX::setpgid(0, $$) // die "setpgid(0, $$): $!"; } close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)})); if (my $op_c = delete $self->{pkt_op_c}) { @@ -598,6 +594,7 @@ sub _lei_atfork_child { $cb->(@_) unless PublicInbox::Eml::warn_ignore(@_) }; } + $SIG{TERM} = sub { exit(128 + 15) }; $current_lei = $persist ? undef : $self; # for SIG{__WARN__} } @@ -1147,9 +1144,10 @@ sub event_step { if ($buf eq '') { _drop_wq($self); # EOF, client disconnected dclose($self); - } elsif ($buf =~ /\A(STOP|CONT)\z/) { + } elsif ($buf =~ /\A(?:STOP|CONT)\z/) { + my $sig = "-$buf"; for my $wq (grep(defined, @$self{@WQ_KEYS})) { - $wq->wq_kill($buf) or $wq->wq_kill_old($buf); + $wq->wq_kill($sig) or $wq->wq_kill_old($sig); } } else { die "unrecognized client signal: $buf";