Server and Cluster Management methods
The following is a list and documentation of the available methods used to manage your server and/or cluster.
- getSystemInfo
- clusterGetServerStatus
- clusterAddServer
- clusterRemoveServer
- clusterDisableServer
- clusterEnableServer
- clusterReconfigureServer
- restartPHP
The getSystemInfo Method
Use this method to get information about the system, including the Zend Server edition and version, PHP version, licensing information, etc. This method produces similar output on all Zend Server systems, and is future compatible.
Method definition
<?php
public function getSystemInfo() { }
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$systemInfo = $server->getSystemInfo();
The clusterGetServerStatus Method
Use this method to get the list of servers in the cluster and the status of each one. On a Zend Server Cluster Manager
with no valid license, this operation fails. This operation causes Zend Server Cluster Manager to check the status of
servers and return fresh, non-cached information. This is different from the Servers List tab in the GUI, which may
present cached information. Users interested in reducing load by caching this information should do it in their own code.
Method definition
<?php
public function clusterGetServerStatus(array $parameters = array()) { }
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$parameter |
array |
array() |
no |
A list of server IDs. If specified, the status is returned for these servers only. If not specified,
the status of all the servers is returned. |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$serversList = $server->clusterGetServerStatus(array($serverId1, $serverId2));
foreach ($serversList as $server) {
/** @var $server \ZendService\ZendServerAPI\DataTypes\ServersList */
echo "Id: " . $server->getId() . PHP_EOL;
echo "Name: " . $server->getName() . PHP_EOL;
}
The clusterAddServer Method
Add a new server to the cluster. On a Zend Server Cluster Manager with no valid license, this operation fails.
Method clusterAddServer definition
<?php
public function clusterAddServer($serverName, $serverUrl, $guiPassword, $propagateSettings = false) { }
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$serverName |
string |
|
yes |
The server name. |
$serverUrl |
string |
|
yes |
The server address as a full HTTP/HTTPS URL. |
$guiPassword |
string |
|
yes |
The server GUI password. |
$propagateSettings |
boolean |
false |
no |
Propagate this server’s current settings to the rest of the cluster. |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$serverName = "server10";
$serverUrl = "https://10.0.0.10:10082/ZendServer";
$guiPassword = "test";
$propagateSettings = false;
$serverInfo = $server->clusterAddServer($serverName, $serverUrl, $guiPassword, $propagateSettings);
The clusterRemoveServer Method
This method removes a server from the cluster. The removal process may be asynchronous if Session Clustering is used.
If this is the case, the initial operation will return an HTTP 202 response. As long as the server is not fully removed,
further calls to remove the same server should be idempotent. On a Zend Server Cluster Manager with no valid license,
this operation fails.
Method clusterRemoveServer definition
<?php
public function clusterRemoveServer($serverId, $force = false) { }
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$serverId |
int |
|
yes |
The id of the server to remove |
$force |
boolean |
false |
no |
Force-remove the server, skipping graceful shutdown process. |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$serversList = $server->clusterGetServerStatus();
// removes all server from the 'general' cluster
foreach ($serversList as $server) {
$server->clusterRemoveServer($server->getId());
}
The clusterEnableServer Method
This method is used to re-enable a cluster member. This process may be asynchronous if Session Clustering is used.
If this is the case, the initial operation will return an HTTP 202 response. This action is idempotent, and running
it on an enabled server will result in a 200 OK response with no consequences. On a Zend Server Cluster Manager with
no valid license this operation fails.
Method clusterEnableServer definition
<?php
public function clusterEnableServer($serverId)
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$serverId |
int |
|
yes |
The server id |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$serversList = $server->clusterGetServerStatus();
// enables all server from the 'general' cluster
foreach ($serversList as $server) {
$server->clusterEnableServer($server->getId());
}
The clusterDisableServer Method
This method disables a cluster member. This process may be asynchronous if Session Clustering is used. If this is
the case, the initial operation returns an HTTP 202 response. As long as the server is not fully disabled, further
calls to this method are idempotent. On a Zend Server Cluster Manager with no valid license, this operation fails.
Method clusterDisableServer definition
<?php
public function clusterDisableServer($serverId)
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$serverId |
int |
|
yes |
The server id |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$serversList = $server->clusterGetServerStatus();
// disables all server from the 'general' cluster
foreach ($serversList as $server) {
$server->clusterDisableServer($server->getId());
}
The restartPhp Method
This method restarts PHP on all servers or on specified servers in the cluster. A 202 response in this case does not
always indicate a successful restart of all servers. Use the clusterGetServerStatus command to check the server(s) status again after a few seconds.
Method restartPhp definition
<?php
public function restartPhp($serverIds = array(), $parallelRestart = false) { }
Parameter
Parameter |
Data Type |
Default value |
Required |
Description |
$serverIds |
array |
array() |
no |
A list of server IDs to restart. If not specified, all servers in the cluster will be restarted. In a single
Zend Server context this parameter is ignored. |
$parallelRestart |
boolean |
false |
no |
Sends the restart command to all servers at the same time. |
Example
<?php
use ZendService\ZendServerAPI\Server;
$server = new Server();
$server->restartPhp();