mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	New LOCK feature.
This commit is contained in:
		
							parent
							
								
									d63ca9cc04
								
							
						
					
					
						commit
						04b194d91a
					
				@ -48,6 +48,12 @@ class Mage_Console
 | 
			
		||||
 | 
			
		||||
        } else if ($this->_args[0] == 'init') {
 | 
			
		||||
            $this->_action = 'init';
 | 
			
		||||
 | 
			
		||||
        } else if ($this->_args[0] == 'lock') {
 | 
			
		||||
            $this->_action = 'lock';
 | 
			
		||||
 | 
			
		||||
        } else if ($this->_args[0] == 'unlock') {
 | 
			
		||||
                $this->_action = 'unlock';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($this->_args as $argument) {
 | 
			
		||||
@ -158,19 +164,21 @@ class Mage_Console
 | 
			
		||||
                        Mage_Console::output('<red>You must indicate a task</red>', 0, 2);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    switch ($this->_args[1]) {
 | 
			
		||||
                        case 'list':
 | 
			
		||||
                            $task->setAction($this->_args[1]);
 | 
			
		||||
                            break;
 | 
			
		||||
 | 
			
		||||
                        case 'rollback':
 | 
			
		||||
                    if ($this->_args[1] == 'list') {
 | 
			
		||||
                            $task->setAction('list');
 | 
			
		||||
 | 
			
		||||
                    } else if ($this->_args[1] == 'rollback') {
 | 
			
		||||
                        if (!isset($this->_args[2])) {
 | 
			
		||||
                            Mage_Console::output('<red>You must indicate a release point</red>', 0, 2);
 | 
			
		||||
                                break 2;
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        $task->setAction($this->_args[1]);
 | 
			
		||||
                        $task->setRelease($this->_args[2]);
 | 
			
		||||
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Mage_Console::output('<red>Invalid Releases task</red>', 0, 2);
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    $task->run($config);
 | 
			
		||||
@ -191,6 +199,16 @@ class Mage_Console
 | 
			
		||||
                    $task->run();
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case 'lock';
 | 
			
		||||
                    $task = new Mage_Task_Lock;
 | 
			
		||||
                    $task->run($config);
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case 'unlock';
 | 
			
		||||
                    $task = new Mage_Task_Lock;
 | 
			
		||||
                    $task->run($config, true);
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case 'upgrade';
 | 
			
		||||
                    $task = new Mage_Task_Upgrade;
 | 
			
		||||
                    $task->run();
 | 
			
		||||
 | 
			
		||||
@ -18,11 +18,17 @@ class Mage_Task_Deploy
 | 
			
		||||
        $this->_startTime = time();
 | 
			
		||||
        $this->_config = $config;
 | 
			
		||||
 | 
			
		||||
        if ($config->getEnvironment() == '') {
 | 
			
		||||
        if ($config->getEnvironmentName() == '') {
 | 
			
		||||
            Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
 | 
			
		||||
        if (file_exists($lockFile)) {
 | 
			
		||||
            Mage_Console::output('<red>This environment is locked!</red>', 0, 2);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Run Pre-Deployment Tasks
 | 
			
		||||
        $this->_runNonDeploymentTasks('pre-deploy', $config, 'Pre-Deployment');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								Mage/Task/Lock.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Mage/Task/Lock.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
<?php
 | 
			
		||||
class Mage_Task_Lock
 | 
			
		||||
{
 | 
			
		||||
    private $_config = null;
 | 
			
		||||
 | 
			
		||||
    public function run(Mage_Config $config, $unlock = false)
 | 
			
		||||
    {
 | 
			
		||||
        $this->_config = $config;
 | 
			
		||||
 | 
			
		||||
        if ($config->getEnvironmentName() == '') {
 | 
			
		||||
            Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
 | 
			
		||||
        if (file_exists($lockFile)) {
 | 
			
		||||
            @unlink($lockFile);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Mage_Console::output('Unlocked deployment to <light_purple>' . $config->getEnvironmentName() . '</light_purple> environment', 1, 2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -31,11 +31,17 @@ class Mage_Task_Releases
 | 
			
		||||
    {
 | 
			
		||||
        $this->_config = $config;
 | 
			
		||||
 | 
			
		||||
        if ($config->getEnvironment() == '') {
 | 
			
		||||
        if ($config->getEnvironmentName() == '') {
 | 
			
		||||
            Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
 | 
			
		||||
        if (file_exists($lockFile)) {
 | 
			
		||||
            Mage_Console::output('<red>This environment is locked!</red>', 0, 2);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Run Tasks for Deployment
 | 
			
		||||
        $hosts = $config->getHosts();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user