]> git.openstreetmap.org Git - dns.git/blobdiff - bin/mkgeo
Add lambton to tile CDN
[dns.git] / bin / mkgeo
index 8cb4687e124fca590eece9372e4d28d55d7a74fa..6944c456c550631034ac1a9045802a4f1845d4e3 100755 (executable)
--- a/bin/mkgeo
+++ b/bin/mkgeo
@@ -9,14 +9,14 @@ use IO::File;
 use Math::Trig qw(deg2rad pip2 great_circle_distance);
 use JSON::XS;
 use LWP::UserAgent;
-use YAML;
+use YAML::XS qw(LoadFile DumpFile);
 
 my $originfile = shift @ARGV;
 my $clusterfile = shift @ARGV;
 my $zone = shift @ARGV;
 my $targetoriginfile = shift @ARGV;
-my $origins = YAML::LoadFile($originfile);
-my $clusters = YAML::LoadFile($clusterfile);
+my $origins = LoadFile($originfile);
+my $clusters = LoadFile($clusterfile);
 my $gdnsname = shift @ARGV;
 my @servers;
 
@@ -72,7 +72,7 @@ if ($ENV{STATUSCAKE_USERNAME} && $ENV{STATUSCAKE_APIKEY})
 
     if (-f "statuscake.yml")
     {
-        $cache = YAML::LoadFile("statuscake.yml");
+        $cache = LoadFile("statuscake.yml");
     }
     else
     {
@@ -119,7 +119,8 @@ if ($ENV{STATUSCAKE_USERNAME} && $ENV{STATUSCAKE_APIKEY})
         }
     }
 
-    YAML::DumpFile("statuscake.yml", $cache);
+    DumpFile("statuscake-$$.yml", $cache);
+    rename("statuscake-$$.yml", "statuscake.yml");
 }
 
 # Mark a cluster as up if any servers are up
@@ -339,7 +340,7 @@ if (defined($gdnsname))
     {
         my $name = $cluster->{name};
 
-        if (@{$cluster->{servers}} > 1)
+        if (@{$cluster->{servers}} > 1 && grep { $_->{status} eq "up" } @{$cluster->{servers}})
         {
             $gdnsweightedfile->print("${name} => {\n");
 
@@ -373,7 +374,7 @@ if (defined($gdnsname))
 }
 
 # Output the target details in origin format if required
-YAML::DumpFile($targetoriginfile, $targetorigins) if $targetoriginfile;
+DumpFile($targetoriginfile, $targetorigins) if $targetoriginfile;
 
 exit 0;