Jump to content

Ping Amazon S3 and Mosso Cloud. This there a better way?


sprintlife

Recommended Posts

Hey guys,

 

Here is what I am doing.  I am storing images on Amazon S3 cloud and Mosso cloud systems.  What I want to do is ping Amazon S3 cloud first to make sure it's online and if it's not I ping the second one that being Mosso cloud system to see if it's online.  The mosso cloud is like a back up in a way.  So here is my function code.  Tell me if there is a better way on doing this...

// constants.php file
define("AMAZON_IMAGES", "s3.amazonaws.com");
define("MOSSO_IMAGES", "cdn.cloudfiles.mosso.com");

 

// function.php file
function images_ping3rdparties($amazonURL, $mossoURL){  
    
    // Going to check if Amazon is working first, if it's not we switch the user over to Mosso.
    // If Mosso down we give the user an error.
    // Amazon = 2, Mosso = 1, Error = 0
    $amazon = @fsockopen("$amazonURL", 80, $errno, $errstr, 2);
    $mosso = @fsockopen("$mossoURL", 80, $errno, $errstr, 2);

    if(!$amazon) {
    	if(!$mosso) {
    	$status = '0'; 	    	
    } else {
    	$status = '1';
    	fclose($mosso);
    	//fclose($amazon);
    }
    } else {
  	$status = '2';
  	fclose($mosso);
  	fclose($amazon);
    }
    return $status;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.