Forum Moderators: coopster

Message Too Old, No Replies

How can I check if a server is up and running?

         

electricocean

8:00 pm on Aug 20, 2005 (gmt 0)

10+ Year Member



Is there any way to check if a server is running and then refresh to it?
maybe something like this:
<?php
$url = "http://www.mysite.com";
if(server_status($url) == true){
header('location : $url');
}
else{
echo "Server down -- TRY AGAIN LATER";
}
?>

I was looking at php.net and i found Memcache::getStats(), but i don't know what that does...

Is there a way to do this?

thanks,
electricocean

Giljorak

12:43 am on Aug 21, 2005 (gmt 0)

10+ Year Member



I used the following to get images from my local server if my remote source(isp web space) was unavailable:
<?php
$data = include('http://myname.my.isp.net/bummer.txt');
if ($data){
$url="http://myname.my.isp.net/";
}else{
$url="http://local.web.storage.area.net/";
}
?>

The file bummer.txt is just an empty file on my isp's web storage area.

I did this because at the time I had limited bandwidth available for my own server and figured that my isp could serve the images faster than my wimpy DSL connection.

This has worked extremely well for me.

electricocean

7:13 pm on Aug 21, 2005 (gmt 0)

10+ Year Member



so i could do

<?php
$url = "http://mysite.com/index.php";
$filename = include($url);
if($filename){
header('Location: $url');
}
else{
echo "Site Down--- try again later";
}
?>
thanks,
electricocean

electricocean

6:00 am on Aug 23, 2005 (gmt 0)

10+ Year Member



i also tried this:

<?php
$url = "http://www.mysite.com/index.php";
if(is_readable($url) && file_exists($url)){
echo "<script language=\"javascript\">
top.location.replace = \"{$url}\";
</script>";
}
else{
echo "Server down -- TRY AGAIN LATER";
}
?>

this always return fals eand outputs "Server down -- TRY AGAIN LATER".

What's wrong?