From 0d574cdb6a43c4549cafabce791ae1f3fb56848b Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Sun, 5 May 2024 08:45:11 -0400 Subject: [PATCH 1/3] tail_logfile: never look at /usr/local/apache/logs/error_log That is ancient and irrelevant, even in testing. --- lib/pause_2017/PAUSE/Web/Controller/User.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pause_2017/PAUSE/Web/Controller/User.pm b/lib/pause_2017/PAUSE/Web/Controller/User.pm index d15ffede7..5b525aeeb 100644 --- a/lib/pause_2017/PAUSE/Web/Controller/User.pm +++ b/lib/pause_2017/PAUSE/Web/Controller/User.pm @@ -302,9 +302,7 @@ sub tail_logfile { my $tail = $req->param("pause99_tail_logfile_1") || 5000; my $file = $PAUSE::Config->{PAUSE_LOG}; - if ($PAUSE::Config->{TESTHOST}) { - $file = "/usr/local/apache/logs/error_log"; # for testing - } + open my $fh, "<", $file or die "Could not open $file: $!"; seek $fh, -$tail, 2; local($/); From 6f65a7b2545371f9a6eb96d6e7ac31208abfb824 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Sun, 5 May 2024 08:52:10 -0400 Subject: [PATCH 2/3] tail_logfile: read from journalctl, not pause.log This means we can stop writing pause.log! Also, this switches from "last n bytes" to "last n lines" and so adjusts the options a bit. --- lib/pause_2017/PAUSE/Web/Controller/User.pm | 19 ++++++++++--------- .../templates/user/tail_logfile.html.ep | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/pause_2017/PAUSE/Web/Controller/User.pm b/lib/pause_2017/PAUSE/Web/Controller/User.pm index 5b525aeeb..8ffcadd00 100644 --- a/lib/pause_2017/PAUSE/Web/Controller/User.pm +++ b/lib/pause_2017/PAUSE/Web/Controller/User.pm @@ -300,17 +300,18 @@ sub tail_logfile { my $pause = $c->stash(".pause"); my $req = $c->req; - my $tail = $req->param("pause99_tail_logfile_1") || 5000; - my $file = $PAUSE::Config->{PAUSE_LOG}; + my $lines = $req->param("pause99_tail_logfile_1") || 1000; - open my $fh, "<", $file or die "Could not open $file: $!"; - seek $fh, -$tail, 2; - local($/); - $/ = "\n"; - <$fh>; - $/ = undef; + my @valid_options = qw(500 1000 10000 20000); + unless (grep {; $lines eq $_ } @valid_options) { + $lines = 500; + } + + my $logs = readpipe("/usr/bin/journalctl --lines $lines --identifier paused"); + + $logs = qq{Error reading PAUSE daemon logs!\n} if $? != 0; - $pause->{tail} = <$fh>; + $pause->{tail} = $logs; } sub change_passwd { diff --git a/lib/pause_2017/templates/user/tail_logfile.html.ep b/lib/pause_2017/templates/user/tail_logfile.html.ep index b7a469320..c67ceb344 100644 --- a/lib/pause_2017/templates/user/tail_logfile.html.ep +++ b/lib/pause_2017/templates/user/tail_logfile.html.ep @@ -2,8 +2,8 @@ % my $pause = stash(".pause") || {};
-<%= select_field pause99_tail_logfile_1 => [qw/2000 5000 10000 20000 40000/]; =%> - +<%= select_field pause99_tail_logfile_1 => [qw/500 1000 10000 20000/]; =%> + From bd8717164e12cdf74a22a1b894f7390b135e3420 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Sun, 5 May 2024 08:54:41 -0400 Subject: [PATCH 3/3] tail_logfile: update test for new line limit options This also removes the thing that was putting text into the PAUSE log, since nothing is going to look at the output. --- t/pause_2017/action/tail_logfile.t | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/t/pause_2017/action/tail_logfile.t b/t/pause_2017/action/tail_logfile.t index 49bb91888..35c24a680 100644 --- a/t/pause_2017/action/tail_logfile.t +++ b/t/pause_2017/action/tail_logfile.t @@ -5,21 +5,12 @@ use Test::PAUSE::Web; use utf8; my $default = { - pause99_tail_logfile_1 => 5000, + pause99_tail_logfile_1 => 500, pause99_tail_logfile_sub => 1, }; Test::PAUSE::Web->setup; -{ - open my $fh, '>', $PAUSE::Config->{PAUSE_LOG}; - say $fh < sub { for my $test (Test::PAUSE::Web->tests_for('user')) { my ($path, $user) = @$test;