I have a PHP page that basically just takes some user input (dates) and puts them into a URL which points to a WEBrick server and initializes some Ruby scripts. Everything works perfectly fine, with one exception. I want to ensure that when my WEBrick server gets kicked or is down for some reason, that PHP can realize it and act accordingly. I tried some basic PHP exception handling, but to no avail. What I have is this:
Code: Select all
try
{
echo "<META http-equiv=\"refresh\" content=\"0;URL=http://harrier:4243/cpa?from=$_POST[FromDate]&to=$_POST[ToDate]\">";
exit;
}
catch(Exception $e)
{
echo 'Message: ' .$e->getMessage();
}
Code: Select all
$str = file_get_contents( 'http://harrier:4243/cpa?from=2008-06-01&to=2008-06-10' );
if ( strpos( $str, '404' ) === FALSE )
{
echo 'The Server is Down';
}
else
{
echo 'The Server is Up';
}
Any and all help is appreciated!
Thanks,
- Jeff