I have several servers - backend, frontend and api. To deploy the code on the servers I use Rocketeer.
I use multiple servers for one connection:
'connections' => array(
'production' => array(
'servers' => array(
array(
'host' => 'xxx.xxx.xxx.xxx', // backend
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
array(
'host' => 'xxx.xxx.xxx.xxx', // api
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
array(
'host' => 'xxx.xxx.xxx.xxx', // frontend
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
),
),
).
For each server performs its tasks.
To determine the current connection, I use the following code in hooks.php
$connection = $task->getConnection();
$server = $connection->connections->getServer();
$credentials = $connection->connections->getServerCredentials($connection->connections->getConnection(), $server);
switch($credentials['host']){
case 'xxx.xxx.xxx.xxx':
$task->runForCurrentRelease('...');
break;
}
The data are uploaded to servers sequentially.
After deploying to last server I can't execute command on previous servers.
How can I execute commands on different servers after deploying? (for example: restart nginx, restart memcached etc.)
I believe this is what you're looking for: http://rocketeer.autopergamene.eu/#/docs/docs/II-Concepts/Events
You should be able to create your own listener for each set of commands.