Commit:    8a6bfe8456f73c8dc1801356c3adeeadada917c2
Author:    Ferenc Kovacs <[email protected]>         Fri, 1 Feb 2013 11:35:51 
+0100
Parents:   2128756a41f2a0ed8e6552672f00bd692d867dc4
Branches:  master

Link:       
http://git.php.net/?p=web/master.git;a=commitdiff;h=8a6bfe8456f73c8dc1801356c3adeeadada917c2

Log:
add an additional test for the round robin balanced servers: they should also 
be able to respond on cc.php.net for their respective cc.
remove them from the rotation (but keep them enabled as an invidual mirror so 
they will continue to work as ccx.php.net and can receive traffic from our php 
based balancing redirects.

Changed paths:
  M  scripts/mirror-test


Diff:
diff --git a/scripts/mirror-test b/scripts/mirror-test
index 67e9b7d..4fc5a51 100755
--- a/scripts/mirror-test
+++ b/scripts/mirror-test
@@ -25,7 +25,8 @@ mysql_select_db("phpmasterdb");
 // Get mirror information for all active mirrors (regardless of their type!)
 $query = "SELECT maintainer, hostname, id, has_search, has_stats, lang,
           UNIX_TIMESTAMP(lastchecked) as lastchecked,
-          UNIX_TIMESTAMP(lastupdated) AS lastupdated
+          UNIX_TIMESTAMP(lastupdated) AS lastupdated,
+         load_balanced
           FROM mirrors WHERE active = 1";
 $result = mysql_query($query) or die("unable to get from the database: " . 
mysql_error());
 
@@ -39,7 +40,7 @@ while ($row = mysql_fetch_array($result)) {
 mysql_free_result($result);
 
 // Check host for errors, inject data into $data and $problem
-function host_has_error($hostname, $filename, &$data, &$problem) {
+function host_has_error($hostname, $filename, &$data, &$problem, 
$spoofed_hostname=FALSE) {
 
     // Open port 80 on the mirror site
     $fp = @fsockopen($hostname, 80, $errno, $errstr, 15);
@@ -52,7 +53,7 @@ function host_has_error($hostname, $filename, &$data, 
&$problem) {
 
     // GET the page from the registered hostname
     $rc = fputs($fp, "GET $filename HTTP/1.0\r\n" .
-                     "Host: {$hostname}\r\n" .
+                     "Host: 
".($spoofed_hostname?$spoofed_hostname:$hostname)."\r\n" .
                      "User-Agent: PHP.net Mirror Site Check\r\n\r\n");
     
     // If we were unable to write to socket, skip mirror site
@@ -162,6 +163,21 @@ foreach ($hosts as $index => $host) {
       continue;
     }
 
+    // if the mirror is used for the load balancing check that it can serve 
the mirror-info for cc.php.net also
+    $lb_data = $lb_problem = '';
+    if ($host['load_balanced'] && host_has_error($host['hostname'], $filename, 
$lb_data, $lb_problem, $host['load_balanced'].'.php.net')) {
+        // remove from rotation
+        $query = "UPDATE mirrors SET load_balanced = '' WHERE hostname = '" . 
$host['hostname'] . "'";
+        $result = mysql_query($query) or die("unable to update the database: 
$query: " . mysql_error());
+       // send an email to systems, when we are stable enough, we should 
change this to php-mirrors@
+        mail(
+            "[email protected]",
+            "Round robin for {$host['hostname']} is deactivated",
+            "The following error occured when testing {$host['hostname']} for 
serving traffic for {$host['load_balanced']}.php.net: \n{$lb_problem}",
+            "From: [email protected]"
+        );
+    }
+
     // Explode information row by delimiter
     $info = explode("|", trim($data));


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to