lemonldap-ng/modules/lemonldap-ng-portal/example/scripts/purgeCentralCache
Xavier Guimard 95424e487a * New manager in progress
* Strange problem with Net::LDAP in mpm-worker environment (not fixed)
 * Clean lock files when using Apache::Session::File
2009-10-30 17:27:36 +00:00

52 lines
1.1 KiB
Perl
Executable File

#!/usr/bin/perl
# Cleaner for Lemonldap::NG : removes old sessions from Apache::Session
#
# This module is written to be used by cron to clean old sessions from
# Apache::Session.
use Lemonldap::NG::Common::Conf;
use Lemonldap::NG::Common::Conf::Constants;
use Lemonldap::NG::Common::Apache::Session;
use strict;
my $lmconf = Lemonldap::NG::Common::Conf->new();
my $conf = $lmconf->getConf or die "Unable to get configuration ($!)";
my $tmp = $conf->{globalStorage};
eval "use $tmp";
die $@ if ($@);
$conf->{timeout} ||= 7200;
my @t;
$tmp->get_key_from_all_sessions(
$conf->{globalStorageOptions},
sub {
my $entry = shift;
my $id = shift;
push @t, $id if ( time - $entry->{_utime} > $conf->{timeout} );
undef;
}
);
for my $id (@t) {
my %h;
eval { tie %h, $tmp, $id, $conf->{globalStorageOptions} };
if ($@) {
next;
}
tied(%h)->delete;
}
if ( $tmp =~ /^Apache::Session::(?:Browseable::)?File$/i ) {
require Apache::Session::Lock::File;
my $l = new Apache::Session::Lock::File;
$l->clean( $conf->{globalStorageOptions}->{LockDirectory},
$conf->{timeout} );
}
1;