mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	New option, max releases.
This commit is contained in:
		
							parent
							
								
									6e3e8e0768
								
							
						
					
					
						commit
						aaa65800d0
					
				@ -29,6 +29,33 @@ class Mage_Task_BuiltIn_Deployment_Releases
 | 
				
			|||||||
                     . ' && '
 | 
					                     . ' && '
 | 
				
			||||||
                     . '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 {
 | 
				
			||||||
 | 
				
			|||||||
@ -81,15 +81,18 @@ 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)
 | 
				
			||||||
 | 
				
			|||||||
@ -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 New Issue
	
	Block a user