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;