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 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 738F51FFAD for ; Mon, 1 Feb 2021 08:28:34 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/21] lei: remove syslog dependency Date: Sun, 31 Jan 2021 22:28:18 -1000 Message-Id: <20210201082833.3293-7-e@80x24.org> In-Reply-To: <20210201082833.3293-1-e@80x24.org> References: <20210201082833.3293-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It doesn't seem necessary now that we redirect and write stuff to errors.log, which gets checked every run. --- lib/PublicInbox/LEI.pm | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 22cd20f6..c0b90451 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -14,10 +14,9 @@ use Getopt::Long (); use Socket qw(AF_UNIX SOCK_SEQPACKET MSG_EOR pack_sockaddr_un); use Errno qw(EPIPE EAGAIN EINTR ECONNREFUSED ENOENT ECONNRESET); use Cwd qw(getcwd); -use POSIX (); +use POSIX qw(strftime); use IO::Handle (); use Fcntl qw(SEEK_SET); -use Sys::Syslog qw(syslog openlog); use PublicInbox::Config; use PublicInbox::Syscall qw(SFD_NONBLOCK EPOLLIN EPOLLET); use PublicInbox::Sigfd; @@ -1007,9 +1006,9 @@ sub lazy_start { warn "$path dev/ino changed, quitting\n"; $path = undef; } - } elsif (defined($path)) { - warn "stat($path): $!, quitting ...\n"; - undef $path; # don't unlink + } elsif (defined($path)) { # ENOENT is common + warn "stat($path): $!, quitting ...\n" if $! != ENOENT; + undef $path; $quit->(); } return 1 if defined($path); @@ -1029,18 +1028,14 @@ sub lazy_start { # STDIN was redirected to /dev/null above, closing STDERR and # STDOUT will cause the calling `lei' client process to finish # reading the <$daemon> pipe. - openlog($path, 'pid', 'user'); local $SIG{__WARN__} = sub { - $current_lei ? err($current_lei, @_) : syslog('warning', "@_"); + $current_lei ? err($current_lei, @_) : warn( + strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(time))," $$ ", @_); }; - my $on_destroy = PublicInbox::OnDestroy->new($$, sub { - syslog('crit', "$@") if $@; - }); open STDERR, '>&STDIN' or die "redirect stderr failed: $!"; open STDOUT, '>&STDIN' or die "redirect stdout failed: $!"; # $daemon pipe to `lei' closed, main loop begins: PublicInbox::DS->EventLoop; - @$on_destroy = (); # cancel on_destroy if we get here exit($exit_code // 0); }