mirror of
https://github.com/manuelkasper/AS-Stats.git
synced 2025-02-20 11:44:12 +08:00
flush cache on exit
This commit is contained in:
parent
705e1687ff
commit
788bdc338f
@ -88,6 +88,7 @@ sub REAPER {
|
||||
|
||||
sub TERM {
|
||||
print "SIGTERM received\n";
|
||||
flush_cache(1);
|
||||
exit 0;
|
||||
}
|
||||
|
||||
@ -627,7 +628,8 @@ sub handleflow {
|
||||
}
|
||||
|
||||
sub flush_cache {
|
||||
if ($childrunning || ((time - $ascache_lastflush) < $ascache_flush_interval)) {
|
||||
my $force = shift;
|
||||
if (!defined($force) && ($childrunning || ((time - $ascache_lastflush) < $ascache_flush_interval))) {
|
||||
# can't/don't want to flush cache right now
|
||||
return;
|
||||
}
|
||||
@ -641,17 +643,21 @@ sub flush_cache {
|
||||
} elsif ($pid != 0) {
|
||||
# in parent
|
||||
$ascache_lastflush = time;
|
||||
for (keys %$ascache) {
|
||||
if ($_ % 10 == $ascache_flush_number % 10) {
|
||||
delete $ascache->{$_};
|
||||
if(!defined($force)){
|
||||
for (keys %$ascache) {
|
||||
if ($_ % 10 == $ascache_flush_number % 10) {
|
||||
delete $ascache->{$_};
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$ascache = ();
|
||||
}
|
||||
$ascache_flush_number++;
|
||||
return;
|
||||
}
|
||||
|
||||
while (my ($as, $cacheent) = each(%$ascache)) {
|
||||
if ($as % 10 == $ascache_flush_number % 10) {
|
||||
if (defined($force) || $as % 10 == $ascache_flush_number % 10) {
|
||||
#print "$$: flushing data for AS $as ($cacheent->{updatets})\n";
|
||||
|
||||
my $rrdfile = getrrdfile($as, $cacheent->{updatets});
|
||||
|
Loading…
x
Reference in New Issue
Block a user