Support multiple space-separated purge hosts
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 8 Feb 2014 18:42:33 +0000 (20:42 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 8 Feb 2014 18:42:33 +0000 (20:42 +0200)
lib/Gruntmaster/Daemon.pm

index 3f4e15a..82da6b8 100644 (file)
@@ -23,6 +23,7 @@ use constant PAGE_SIZE => 10;
 ##################################################
 
 my $ua = LWP::UserAgent->new;
+my @purge_hosts = exists $ENV{PURGE_HOSTS} ? split ' ', $ENV{PURGE_HOSTS} : ();
 
 sub safe_can_nodie {
   my ($type, $sub, $name) = @_;
@@ -41,9 +42,10 @@ sub safe_can {
 }
 
 sub purge {
-       return unless $ENV{PURGE_HOST};
-       my $req = HTTP::Request->new(PURGE => "http://$ENV{PURGE_HOST}$_[0]");
-       $ua->request($req)
+       for my $host (@purge_hosts) {
+               my $req = HTTP::Request->new(PURGE => "http://$host$_[0]");
+               $ua->request($req)
+       }
 }
 
 sub process{
This page took 0.024746 seconds and 4 git commands to generate.