]> iEval git - gruntmaster-daemon.git/commitdiff
Support new purge interface
authorMarius Gavrilescu <marius@ieval.ro>
Thu, 6 Feb 2014 11:54:20 +0000 (13:54 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Thu, 6 Feb 2014 11:54:20 +0000 (13:54 +0200)
lib/Gruntmaster/Daemon.pm

index 156d7435adcff83e3fa81478aee6b7fc2fb69f39..3f4e15a5f2f4acf629a0c660ee7d4228ed5d0abc 100644 (file)
@@ -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{
This page took 0.025392 seconds and 4 git commands to generate.