From 72934d394cb1c8f7added73a3f49686ac048ea7f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 26 Sep 2020 12:16:30 +0100 Subject: [PATCH] #740 --logfiles=8 and --logsize=10 (MB) options to netdisco-backend and netdisco-web --- bin/netdisco-backend | 13 +++++++++++-- bin/netdisco-web | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/netdisco-backend b/bin/netdisco-backend index a9c43c62..3d10ce59 100755 --- a/bin/netdisco-backend +++ b/bin/netdisco-backend @@ -43,6 +43,15 @@ use Daemon::Control; use Filesys::Notify::Simple; use File::Copy; +use Getopt::Long; +Getopt::Long::Configure ("pass_through"); + +my ($logfiles, $logsize) = (8,10); +my $result = GetOptions( + 'logfiles=i' => \$logfiles, + 'logsize=i' => \$logsize, +); + use App::Netdisco::Environment; my $config = ($ENV{PLACK_ENV} || $ENV{DANCER_ENVIRONMENT}) .'.yml'; @@ -156,13 +165,13 @@ sub rotate_logs { my $child = shift; return unless (-f $log_file) and - ((-s $log_file) > (10 * 1024768)); + ((-s $log_file) > ($logsize * 1024768)); my @files = glob file($log_dir, '*'); foreach my $f (reverse sort @files) { next unless $f =~ m/$log_file\.(\d)$/; my $pos = $1; - unlink $f if $pos == 7; + unlink $f if $pos == ($logfiles - 1); my $next = $pos + 1; (my $newf = $f) =~ s/\.$pos$/.$next/; rename $f, $newf; diff --git a/bin/netdisco-web b/bin/netdisco-web index 8a1f6557..29164287 100755 --- a/bin/netdisco-web +++ b/bin/netdisco-web @@ -44,6 +44,15 @@ use Filesys::Notify::Simple; use IO::File; use File::Copy; +use Getopt::Long; +Getopt::Long::Configure ("pass_through"); + +my ($logfiles, $logsize) = (8,10); +my $result = GetOptions( + 'logfiles=i' => \$logfiles, + 'logsize=i' => \$logsize, +); + use App::Netdisco::Environment; my $config = ($ENV{PLACK_ENV} || $ENV{DANCER_ENVIRONMENT}) .'.yml'; @@ -171,13 +180,13 @@ sub rotate_logs { my $child = shift; return unless (-f $log_file) and - ((-s $log_file) > (10 * 1024768)); + ((-s $log_file) > ($logsize * 1024768)); my @files = glob file($log_dir, '*'); foreach my $f (reverse sort @files) { next unless $f =~ m/$log_file\.(\d)$/; my $pos = $1; - unlink $f if $pos == 7; + unlink $f if $pos == ($logfiles - 1); my $next = $pos + 1; (my $newf = $f) =~ s/\.$pos$/.$next/; rename $f, $newf;