Post subject: Short downtime this morning Posted: Sun Aug 30, 2009 12:30 pm
Site Administrator
Joined Fri Aug 18, 2006 11:47 am
Posts 11407
Location Merseyside, United Kingdom
Favourite OS Microsoft Windows 7 Ultimate x64
Hello all,
There was a short downtime this morning of around 4 hours, when one of the crons failed to correctly run, causing the bandwidth stats to stop working. This caused a site-wide error causing each page load to take up to 5 minutes to complete. It only affected BetaArchive and none of the other websites hosted on the server.
Because of this error I have now implemented a fix. The fix checks to see if the stats are available before attempting to include the information into the script from the external http server the stats run from. If it was unavailable, it would cause a hang until the connection timed out. Now it waits no longer than 1 second before timing out, allowing the page to continue loading regardless.
Here is quick example of the fix code which may help anyone with a similar problem.
Code:
function isalive($port) { if (!is_numeric($port)) return false; $socket = @fsockopen("127.0.0.1:81", $port, $errno, $errstr, 1); if (!$socket) return false; else { fclose($socket); return true; } }
if (isalive(80)){ $bandwidth = @file_get_contents("http://127.0.0.1:81/bandwidth.txt")); } else{ echo(""); }
Post subject: Re: Short downtime this morning Posted: Sun Aug 30, 2009 4:17 pm
Site Administrator
Joined Fri Aug 18, 2006 11:47 am
Posts 11407
Location Merseyside, United Kingdom
Favourite OS Microsoft Windows 7 Ultimate x64
I tried that, it doesn't work, or I'd use that method. I explored it in the past. Something to do with php itself ignoring the ini change. Don't ask, lol.
Post subject: Re: Short downtime this morning Posted: Sun Aug 30, 2009 4:48 pm
Site Administrator
Joined Fri Aug 18, 2006 11:47 am
Posts 11407
Location Merseyside, United Kingdom
Favourite OS Microsoft Windows 7 Ultimate x64
Actually I'm using neither port. I changed the entire example to use fake information, since it was just an example. I'd also rather people didn't know the actual url
Anyway, the script uses your caching code, so it only requests it once every 5 seconds maximum anyway
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.