Skip to content

Commit

Permalink
Merge pull request #1051 from pluseg/1012-native-ssh-errors
Browse files Browse the repository at this point in the history
Change output of errors for native ssh (#1012)
  • Loading branch information
antonmedv authored Feb 25, 2017
2 parents 1f66ef7 + eb9bb7e commit fa05a68
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Changed
- Autoload functions via Composer [#1015](https://github.com/deployphp/deployer/pull/1015)
- Add task queue:restart for Laravel recipe [#1007](https://github.com/deployphp/deployer/pull/1007)
- Changed output of errors for native ssh [#1012](https://github.com/deployphp/deployer/issues/1012)

### Fixed
- Fixed `Can not share same dirs` for shared folders having similar names [#995](https://github.com/deployphp/deployer/issues/995)
Expand All @@ -20,8 +22,6 @@
- Fixed creating non-existed `writable_dirs` [#1000](https://github.com/deployphp/deployer/pull/1000)
- Fixed uploading files with spaces in a path via Native SSH [#1010](https://github.com/deployphp/deployer/issues/1010)

### Changed
- Add task queue:restart for Laravel recipe [#1007](https://github.com/deployphp/deployer/pull/1007)

## v4.2.1
[v4.2.0...v4.2.1](https://github.com/deployphp/deployer/compare/v4.2.0...v4.2.1)
Expand Down
34 changes: 22 additions & 12 deletions src/Server/Remote/NativeSsh.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Deployer\Server\Configuration;
use Deployer\Server\ServerInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class NativeSsh implements ServerInterface
Expand Down Expand Up @@ -49,7 +50,6 @@ public function run($command)
$serverConfig = $this->getConfiguration();
$sshOptions = [
'-A',
'-q',
'-o UserKnownHostsFile=/dev/null',
'-o StrictHostKeyChecking=no'
];
Expand Down Expand Up @@ -85,12 +85,17 @@ public function run($command)

$sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);

$process = new Process($sshCommand);
$process
->setPty($serverConfig->getPty())
->setTimeout(null)
->setIdleTimeout(null)
->mustRun();
try {
$process = new Process($sshCommand);
$process
->setPty($serverConfig->getPty())
->setTimeout(null)
->setIdleTimeout(null)
->mustRun();
} catch (ProcessFailedException $exception) {
$errorMessage = \Deployer\isDebug() ? $exception->getMessage() : $process->getErrorOutput();
throw new \RuntimeException($errorMessage);
}

return $process->getOutput();
}
Expand Down Expand Up @@ -162,11 +167,16 @@ public function scpCopy($target, $target2)

$scpCommand = 'scp ' . implode(' ', $scpOptions) . ' ' . escapeshellarg($target) . ' ' . escapeshellarg($target2);

$process = new Process($scpCommand);
$process
->setTimeout(null)
->setIdleTimeout(null)
->mustRun();
try {
$process = new Process($scpCommand);
$process
->setTimeout(null)
->setIdleTimeout(null)
->mustRun();
} catch (ProcessFailedException $exception) {
$errorMessage = \Deployer\isDebug() ? $exception->getMessage() : $process->getErrorOutput();
throw new \RuntimeException($errorMessage);
}

return $process->getOutput();
}
Expand Down

0 comments on commit fa05a68

Please sign in to comment.