From: Marius Gavrilescu Date: Thu, 6 Feb 2014 11:54:20 +0000 (+0200) Subject: Support new purge interface X-Git-Tag: 5999.000_002~10 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=064332cd403d5b205c43be0dee53c55ab399e395;p=gruntmaster-daemon.git Support new purge interface --- diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 156d743..3f4e15a 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -16,11 +16,14 @@ use Sys::Hostname qw/hostname/; use Time::HiRes qw/time/; use Try::Tiny; use Log::Log4perl qw/get_logger/; +use LWP::UserAgent; use constant PAGE_SIZE => 10; ################################################## +my $ua = LWP::UserAgent->new; + sub safe_can_nodie { my ($type, $sub, $name) = @_; @@ -37,6 +40,12 @@ sub safe_can { safe_can_nodie @_ or get_logger->logdie("No such \l$type: '$name'"); } +sub purge { + return unless $ENV{PURGE_HOST}; + my $req = HTTP::Request->new(PURGE => "http://$ENV{PURGE_HOST}$_[0]"); + $ua->request($req) +} + sub process{ my $job = shift; @@ -112,6 +121,11 @@ sub process{ PUBLISH genpage => "$log/@{[$page - 1]}.html"; PUBLISH genpage => "$log/$page.html"; PUBLISH genpage => "$log/@{[$page + 1]}.html"; + + purge "/$log/job/$job"; + purge "/$log/"; + purge "/$log/st"; + purge "/$log/$_" for $page - 1, $page, $page + 1; } sub got_job{