本文整理汇总了PHP中pts_client::register_phoromatic_server方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::register_phoromatic_server方法的具体用法?PHP pts_client::register_phoromatic_server怎么用?PHP pts_client::register_phoromatic_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::register_phoromatic_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_server_addressing
protected static function setup_server_addressing($server_string = null)
{
if (isset($server_string[0]) && strpos($server_string[0], '/', strpos($server_string[0], ':')) > 6) {
pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to connect to Phoromatic Server: ' . $server_string[0]);
self::$account_id = substr($server_string[0], strrpos($server_string[0], '/') + 1);
self::$server_address = substr($server_string[0], 0, strpos($server_string[0], ':'));
self::$server_http_port = substr($server_string[0], strlen(self::$server_address) + 1, -1 - strlen(self::$account_id));
pts_client::$display->generic_heading('Server IP: ' . self::$server_address . PHP_EOL . 'Server HTTP Port: ' . self::$server_http_port . PHP_EOL . 'Account ID: ' . self::$account_id);
pts_client::register_phoromatic_server(self::$server_address, self::$server_http_port);
} else {
if (($last_server = trim(pts_module::read_file('last-phoromatic-server'))) && !empty($last_server)) {
pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to connect to last server connection: ' . $last_server);
$last_account_id = substr($last_server, strrpos($last_server, '/') + 1);
$last_server_address = substr($last_server, 0, strpos($last_server, ':'));
$last_server_http_port = substr($last_server, strlen($last_server_address) + 1, -1 - strlen($last_account_id));
pts_client::$pts_logger && pts_client::$pts_logger->log('Last Server IP: ' . $last_server_address . ' Last Server HTTP Port: ' . $last_server_http_port . ' Last Account ID: ' . $last_account_id);
for ($i = 0; $i < 10; $i++) {
$server_response = phoromatic::upload_to_remote_server(array('r' => 'ping'), $last_server_address, $last_server_http_port, $last_account_id);
$server_response = json_decode($server_response, true);
if ($server_response && isset($server_response['phoromatic']['ping'])) {
self::$server_address = $last_server_address;
self::$server_http_port = $last_server_http_port;
self::$account_id = $last_account_id;
pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection restored');
pts_client::register_phoromatic_server(self::$server_address, self::$server_http_port);
break;
} else {
pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection failed');
sleep(12 * ($i + 1));
}
}
}
}
if (self::$server_address == null) {
$archived_servers = pts_client::available_phoromatic_servers();
if (!empty($archived_servers)) {
pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to auto-discover Phoromatic Servers');
self::attempt_phoromatic_server_auto_discover($archived_servers);
}
}
if (self::$server_address == null || self::$server_http_port == null || self::$account_id == null) {
pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection setup failed');
echo PHP_EOL . 'You must pass the Phoromatic Server information as an argument to phoromatic.connect, or otherwise configure your network setup.' . PHP_EOL . ' e.g. phoronix-test-suite phoromatic.connect 192.168.1.2:5555/I0SSJY' . PHP_EOL . PHP_EOL;
if (PTS_IS_DAEMONIZED_SERVER_PROCESS && !empty($archived_servers)) {
echo 'The Phoromatic client appears to be running as a system service/daemon so will attempt to continue auto-polling to find the Phoromatic Server.' . PHP_EOL . PHP_EOL;
$success = false;
do {
pts_client::$pts_logger && pts_client::$pts_logger->log('Will auto-poll connected servers every 90 seconds looking for a claim by a Phoromatic Server');
sleep(90);
$success = self::attempt_phoromatic_server_auto_discover($archived_servers);
} while ($success == false);
} else {
return false;
}
}
return true;
}