/** * Execute a shell command via SSH * * @param mixed $command * @param \TYPO3\Deploy\Domain\Model\Node $node * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment * @return array */ protected function executeRemoteCommand($command, Node $node, Deployment $deployment) { $command = $this->prepareCommand($command); $deployment->getLogger()->log(' $' . $node->getName() . ': "' . $command . '"', LOG_DEBUG); $username = $node->getOption('username'); $hostname = $node->getHostname(); $returnedOutput = ''; // TODO Get SSH options from node or deployment $fp = popen('ssh -A ' . $username . '@' . $hostname . ' ' . escapeshellarg($command) . ' 2>&1', 'r'); while (($line = fgets($fp)) !== FALSE) { $deployment->getLogger()->log(' > ' . rtrim($line)); $returnedOutput .= $line; } $exitCode = pclose($fp); return array($exitCode, $returnedOutput); }
/** * Execute a stage for a node and application * * @param string $stage * @param \TYPO3\Deploy\Domain\Model\Node $node * @param \TYPO3\Deploy\Domain\Model\Application $application * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment * @return void */ protected function executeStage($stage, Node $node, Application $application, Deployment $deployment) { foreach (array('_', $application->getName()) as $applicationName) { $label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName; if (isset($this->tasks['stage'][$applicationName][$stage])) { $deployment->getLogger()->log('Executing stage "' . $stage . '" on "' . $node->getName() . '" ' . $label, LOG_DEBUG); foreach ($this->tasks['stage'][$applicationName][$stage] as $task) { $this->executeTask($task, $node, $application, $deployment); } } } }
/** * Add a node * * @param \TYPO3\Deploy\Domain\Model\Node $node * @return void */ public function addNode(Node $node) { $this->nodes[$node->getName()] = $node; }