diff --git a/CHANGELOG.md b/CHANGELOG.md index d3de18288..5923f4f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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) diff --git a/src/Server/Remote/NativeSsh.php b/src/Server/Remote/NativeSsh.php index 47d18fcfb..c33848dee 100644 --- a/src/Server/Remote/NativeSsh.php +++ b/src/Server/Remote/NativeSsh.php @@ -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 @@ -49,7 +50,6 @@ public function run($command) $serverConfig = $this->getConfiguration(); $sshOptions = [ '-A', - '-q', '-o UserKnownHostsFile=/dev/null', '-o StrictHostKeyChecking=no' ]; @@ -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(); } @@ -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(); }