mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Time information feature.
This commit is contained in:
		
							parent
							
								
									b252555655
								
							
						
					
					
						commit
						6e3e8e0768
					
				@ -14,6 +14,7 @@ class Mage_Task_Add
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $releasesConfig = 'releases:' . PHP_EOL 
 | 
					            $releasesConfig = 'releases:' . PHP_EOL 
 | 
				
			||||||
                            . '  enabled: true' . PHP_EOL
 | 
					                            . '  enabled: true' . PHP_EOL
 | 
				
			||||||
 | 
					                            . '  max: 10' . PHP_EOL
 | 
				
			||||||
                            . '  symlink: current' . PHP_EOL
 | 
					                            . '  symlink: current' . PHP_EOL
 | 
				
			||||||
                            . '  directory: releases' . PHP_EOL;
 | 
					                            . '  directory: releases' . PHP_EOL;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,10 @@ class Mage_Task_Deploy
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    private $_config = null;
 | 
					    private $_config = null;
 | 
				
			||||||
    private $_releaseId = null;
 | 
					    private $_releaseId = null;
 | 
				
			||||||
 | 
					    private $_startTime = null;
 | 
				
			||||||
 | 
					    private $_startTimeHosts = null;
 | 
				
			||||||
 | 
					    private $_endTimeHosts = null;
 | 
				
			||||||
 | 
					    private $_hostsCount = 0;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function __construct()
 | 
					    public function __construct()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -11,6 +15,7 @@ class Mage_Task_Deploy
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    public function run(Mage_Config $config)
 | 
					    public function run(Mage_Config $config)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $this->_startTime = time();
 | 
				
			||||||
        $this->_config = $config;
 | 
					        $this->_config = $config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Run Pre-Deployment Tasks
 | 
					        // Run Pre-Deployment Tasks
 | 
				
			||||||
@ -23,7 +28,9 @@ class Mage_Task_Deploy
 | 
				
			|||||||
            Mage_Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, skipping deployment tasks.</dark_gray>', 1, 3);
 | 
					            Mage_Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, skipping deployment tasks.</dark_gray>', 1, 3);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->_startTimeHosts = time();
 | 
				
			||||||
            foreach ($hosts as $host) {
 | 
					            foreach ($hosts as $host) {
 | 
				
			||||||
 | 
					                $this->_hostsCount++;
 | 
				
			||||||
                $config->setHost($host);
 | 
					                $config->setHost($host);
 | 
				
			||||||
                $tasks = 0;
 | 
					                $tasks = 0;
 | 
				
			||||||
                $completedTasks = 0;
 | 
					                $completedTasks = 0;
 | 
				
			||||||
@ -68,11 +75,21 @@ class Mage_Task_Deploy
 | 
				
			|||||||
                    Mage_Console::output('Deployment to <dark_gray>' . $config->getHost() . '</dark_gray> compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					                    Mage_Console::output('Deployment to <dark_gray>' . $config->getHost() . '</dark_gray> compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            $this->_endTimeHosts = time();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 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
 | 
				
			||||||
 | 
					        if ($this->_hostsCount > 0) {
 | 
				
			||||||
 | 
					            $timeTextPerHost = $this->_transcurredTime(round(($this->_endTimeHosts - $this->_startTimeHosts) / $this->_hostsCount));
 | 
				
			||||||
 | 
					            Mage_Console::output('Average time per host: <dark_gray>' . $timeTextPerHost . '</dark_gray>.');            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function _runNonDeploymentTasks($stage, Mage_Config $config, $title)
 | 
					    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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,9 +1,12 @@
 | 
				
			|||||||
#staging
 | 
					#staging
 | 
				
			||||||
deployment:
 | 
					deployment:
 | 
				
			||||||
  user: stg_user
 | 
					  user: root
 | 
				
			||||||
  from: ./
 | 
					  from: ./
 | 
				
			||||||
  to: /var/www/vhosts/example.com/staging
 | 
					  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:
 | 
					tasks:
 | 
				
			||||||
  pre-deploy:
 | 
					  pre-deploy:
 | 
				
			||||||
    - scm/update
 | 
					    - scm/update
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user