mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-09 01:02:15 +02:00
New option, max releases.
This commit is contained in:
parent
6e3e8e0768
commit
aaa65800d0
|
@ -27,8 +27,35 @@ class Mage_Task_BuiltIn_Deployment_Releases
|
||||||
. ' && '
|
. ' && '
|
||||||
. 'chown -h ' . $userGroup . ' ' . $symlink
|
. 'chown -h ' . $userGroup . ' ' . $symlink
|
||||||
. ' && '
|
. ' && '
|
||||||
. 'chown -R ' . $userGroup . ' ' . $currentCopy;
|
. 'chown -R ' . $userGroup . ' ' . $currentCopy;
|
||||||
$result = $this->_runRemoteCommand($command);
|
$result = $this->_runRemoteCommand($command);
|
||||||
|
|
||||||
|
// Count Releases
|
||||||
|
$maxReleases = $this->_config->release('max', false);
|
||||||
|
if (($maxReleases !== false) && ($maxReleases > 0)) {
|
||||||
|
$releasesList = '';
|
||||||
|
$countReleasesFetch = $this->_runRemoteCommand('ls -1 ' . $releasesDirectory, $releasesList);
|
||||||
|
$releasesList = trim($releasesList);
|
||||||
|
|
||||||
|
if ($releasesList != '') {
|
||||||
|
$releasesList = explode(PHP_EOL, $releasesList);
|
||||||
|
if (count($releasesList) > $maxReleases) {
|
||||||
|
$releasesToDelete = array_diff($releasesList, array($this->_config->getReleaseId()));
|
||||||
|
sort($releasesToDelete);
|
||||||
|
$releasesToDeleteCount = count($releasesToDelete) - $maxReleases;
|
||||||
|
$releasesToDelete = array_slice($releasesToDelete, 0, $releasesToDeleteCount + 1);
|
||||||
|
|
||||||
|
foreach ($releasesToDelete as $releaseIdToDelete) {
|
||||||
|
$directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete;
|
||||||
|
if ($directoryToDelete != '/') {
|
||||||
|
$command = 'rm -rf ' . $directoryToDelete;
|
||||||
|
$result = $result && $this->_runRemoteCommand($command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Mage_Task_Deploy
|
||||||
|
|
||||||
if ($config->release('enabled', false) == true) {
|
if ($config->release('enabled', false) == true) {
|
||||||
$config->setReleaseId($this->_releaseId);
|
$config->setReleaseId($this->_releaseId);
|
||||||
array_push($tasksToRun, 'deployment/releases');
|
array_push($tasksToRun, 'deployment/releases');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($tasksToRun) == 0) {
|
if (count($tasksToRun) == 0) {
|
||||||
|
@ -80,18 +80,21 @@ class Mage_Task_Deploy
|
||||||
|
|
||||||
// Run Post-Deployment Tasks
|
// Run Post-Deployment Tasks
|
||||||
$this->_runNonDeploymentTasks('post-deploy', $config, 'Post-Deployment');
|
$this->_runNonDeploymentTasks('post-deploy', $config, 'Post-Deployment');
|
||||||
|
|
||||||
// Time Information General
|
|
||||||
$timeText = $this->_transcurredTime(time() - $this->_startTime);
|
|
||||||
Mage_Console::output('Total time: <dark_gray>' . $timeText . '</dark_gray>.');
|
|
||||||
|
|
||||||
// Time Information Hosts
|
// Time Information Hosts
|
||||||
if ($this->_hostsCount > 0) {
|
if ($this->_hostsCount > 0) {
|
||||||
|
$timeTextHost = $this->_transcurredTime($this->_endTimeHosts - $this->_startTimeHosts);
|
||||||
|
Mage_Console::output('Average time for deployment: <dark_gray>' . $timeTextHost . '</dark_gray>.');
|
||||||
|
|
||||||
$timeTextPerHost = $this->_transcurredTime(round(($this->_endTimeHosts - $this->_startTimeHosts) / $this->_hostsCount));
|
$timeTextPerHost = $this->_transcurredTime(round(($this->_endTimeHosts - $this->_startTimeHosts) / $this->_hostsCount));
|
||||||
Mage_Console::output('Average time per host: <dark_gray>' . $timeTextPerHost . '</dark_gray>.');
|
Mage_Console::output('Average time per host: <dark_gray>' . $timeTextPerHost . '</dark_gray>.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time Information General
|
||||||
|
$timeText = $this->_transcurredTime(time() - $this->_startTime);
|
||||||
|
Mage_Console::output('Total time: <dark_gray>' . $timeText . '</dark_gray>.', 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _runNonDeploymentTasks($stage, Mage_Config $config, $title)
|
private function _runNonDeploymentTasks($stage, Mage_Config $config, $title)
|
||||||
{
|
{
|
||||||
$tasksToRun = $config->getTasks($stage);
|
$tasksToRun = $config->getTasks($stage);
|
||||||
|
|
|
@ -12,6 +12,7 @@ deployment:
|
||||||
- application/data/cache/twig/*
|
- application/data/cache/twig/*
|
||||||
releases:
|
releases:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
max: 5
|
||||||
symlink: current
|
symlink: current
|
||||||
directory: releases
|
directory: releases
|
||||||
hosts:
|
hosts:
|
||||||
|
|
Loading…
Reference in a new issue