cvs: phpweb / manual-lookup.php /error index.php /include loadavg.inc
| From: | Wez Furlong | Date: | Thu, 22 May 2003 17:31:45 +0000 |
| Subject: | cvs: phpweb / manual-lookup.php /error index.php /include loadavg.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-17904@lists.php.net to get a copy of this message | ||
wez Thu May 22 13:31:45 2003 EDT
Added files:
/phpweb/include loadavg.inc
Modified files:
/phpweb/error index.php
/phpweb manual-lookup.php
Log:
Add primitive load balancing.
Index: phpweb/error/index.php
diff -u phpweb/error/index.php:1.113 phpweb/error/index.php:1.114
--- phpweb/error/index.php:1.113 Sat May 17 09:54:59 2003
+++ phpweb/error/index.php Thu May 22 13:31:44 2003
@@ -1,6 +1,6 @@
<?php
-// $Id: index.php,v 1.113 2003/05/17 13:54:59 goba Exp $
+// $Id: index.php,v 1.114 2003/05/22 17:31:44 wez Exp $
/*
@@ -203,6 +203,7 @@
// ============================================================================
// Try to find the page using the preferred language as a manual page
+include_once 'loadavg.inc';
include_once "manual-lookup.inc";
$try = find_manual_page($LANG, $URI);
if ($try) { mirror_redirect($try); }
Index: phpweb/manual-lookup.php
diff -u phpweb/manual-lookup.php:1.20 phpweb/manual-lookup.php:1.21
--- phpweb/manual-lookup.php:1.20 Wed Sep 11 12:39:53 2002
+++ phpweb/manual-lookup.php Thu May 22 13:31:44 2003
@@ -1,6 +1,7 @@
<?php // -*- C++ -*-
require_once 'prepend.inc';
+require_once 'loadavg.inc';
require_once 'manual-lookup.inc';
if (!$function && $pattern) $function = $pattern;
Index: phpweb/include/loadavg.inc
+++ phpweb/include/loadavg.inc
<?php # vim:ft=php
/* Offload to the visitors nearest mirror if the load is too high.
* getloadavg() function used here is currently only available on the www.php.net
* machine. */
function check_load()
{
global $COUNTRY, $MIRRORS;
if (!function_exists("getloadavg")) {
return;
}
$l = getloadavg();
if (is_array($l) && $l[0] > 10) {
/* offload them to their favourite mirror */
foreach ($MIRRORS as $murl => $mirror) {
if (mirror_country($murl) == $COUNTRY && mirror_status($murl) == MIRROR_OK) {
header("Location: $murl" . $_SERVER['REQUEST_URI']);
header("X-PHP-Load: Too-high, try this mirror");
exit;
}
}
header("Status: 503 Server too busy, try again later");
exit;
}
}
check_load();
?>