public function deploy() { $releaseId = $this->dataBase->startRelease(); $ssh = new Net_SSH2(SSH_SERVER); $key = new Crypt_RSA(); $key->setPassword(SSH_PASSWORD); $key->loadKey(file_get_contents(PATH_TO_PRIVATE_KEY)); if (!$ssh->login(SSH_LOGIN, $key)) { $this->dataBase->logStep($releaseId, 'ssh ' . SSH_SERVER, ['error' => 'Login failed'], 1); exit('Login Failed'); } $ssh->enableQuietMode(); $command = $this->bash->dtLock('sandbox-mercury', 'mercury'); $output['success'] = $ssh->exec($command); $output['error'] = $ssh->getStdError(); $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus()); $command = $this->bash->dtPrep('sandbox-mercury', 'mercury', ["mercury" => "dev"]); $output['success'] = $ssh->exec($command); $output['error'] = $ssh->getStdError(); $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus()); $command = $this->bash->dtPush('sandbox-mercury', 'mercury'); $output['success'] = $ssh->exec($command); $output['error'] = $ssh->getStdError(); $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus()); }
/** * @param $command * * @throws \RuntimeException * @throws \Jumper\Exception\CommunicatorException * @return String */ public function run($command) { $result = $this->ssh->exec($command); if ($result === false) { throw new CommunicatorException($this->ssh->getLastError()); } $error = $this->ssh->getStdError(); if (!empty($error)) { throw new \RuntimeException($error); } return $result; }