diff --git a/Mage/Task/Add.php b/Mage/Task/Add.php index d856d24..78dd078 100644 --- a/Mage/Task/Add.php +++ b/Mage/Task/Add.php @@ -14,6 +14,7 @@ class Mage_Task_Add } else { $releasesConfig = 'releases:' . PHP_EOL . ' enabled: true' . PHP_EOL + . ' max: 10' . PHP_EOL . ' symlink: current' . PHP_EOL . ' directory: releases' . PHP_EOL; diff --git a/Mage/Task/Deploy.php b/Mage/Task/Deploy.php index 62e1bb0..c8e7f9b 100644 --- a/Mage/Task/Deploy.php +++ b/Mage/Task/Deploy.php @@ -3,6 +3,10 @@ class Mage_Task_Deploy { private $_config = null; private $_releaseId = null; + private $_startTime = null; + private $_startTimeHosts = null; + private $_endTimeHosts = null; + private $_hostsCount = 0; public function __construct() { @@ -11,6 +15,7 @@ class Mage_Task_Deploy public function run(Mage_Config $config) { + $this->_startTime = time(); $this->_config = $config; // Run Pre-Deployment Tasks @@ -23,7 +28,9 @@ class Mage_Task_Deploy Mage_Console::output('Warning! No hosts defined, skipping deployment tasks.', 1, 3); } else { + $this->_startTimeHosts = time(); foreach ($hosts as $host) { + $this->_hostsCount++; $config->setHost($host); $tasks = 0; $completedTasks = 0; @@ -68,11 +75,21 @@ class Mage_Task_Deploy Mage_Console::output('Deployment to ' . $config->getHost() . ' compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } } + $this->_endTimeHosts = time(); } // Run Post-Deployment Tasks $this->_runNonDeploymentTasks('post-deploy', $config, 'Post-Deployment'); + // Time Information General + $timeText = $this->_transcurredTime(time() - $this->_startTime); + Mage_Console::output('Total time: ' . $timeText . '.'); + + // Time Information Hosts + if ($this->_hostsCount > 0) { + $timeTextPerHost = $this->_transcurredTime(round(($this->_endTimeHosts - $this->_startTimeHosts) / $this->_hostsCount)); + Mage_Console::output('Average time per host: ' . $timeTextPerHost . '.'); + } } private function _runNonDeploymentTasks($stage, Mage_Config $config, $title) @@ -127,5 +144,25 @@ class Mage_Task_Deploy } - + private function _transcurredTime($time) + { + $hours = floor($time / 3600); + $minutes = floor(($time - ($hours * 3600)) / 60); + $seconds = $time - ($minutes * 60) - ($hours * 3600); + $timeText = array(); + + if ($hours > 0) { + $timeText[] = $hours . ' hours'; + } + + if ($minutes > 0) { + $timeText[] = $minutes . ' minutes'; + } + + if ($seconds > 0) { + $timeText[] = $seconds . ' seconds'; + } + + return implode(' ', $timeText); + } } \ No newline at end of file diff --git a/docs/example-config/.mage/config/environment/staging.yml b/docs/example-config/.mage/config/environment/staging.yml index 901107b..7c01193 100644 --- a/docs/example-config/.mage/config/environment/staging.yml +++ b/docs/example-config/.mage/config/environment/staging.yml @@ -1,9 +1,12 @@ #staging deployment: - user: stg_user + user: root from: ./ to: /var/www/vhosts/example.com/staging -hosts: /tmp/current-staging-hosts.txt +#hosts: /tmp/current-staging-hosts.txt +hosts: + - s01.example.com:22 + - s02.example.com tasks: pre-deploy: - scm/update