diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6d3dab3..170248821 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) @@ -18,8 +20,6 @@ - Fixed possibility to use PEM files with Native SSH - Fixed old releases not being cleaned up when keep_releases reduced by more than half. -### 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 1e235f197..483bd2162 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 @@ -85,12 +86,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\isVerbose() ? $exception->getMessage() : $process->getErrorOutput(); + throw new \RuntimeException($errorMessage); + } return $process->getOutput(); } @@ -159,11 +165,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\isVerbose() ? $exception->getMessage() : $process->getErrorOutput(); + throw new \RuntimeException($errorMessage); + } return $process->getOutput(); } @@ -269,7 +280,10 @@ public function initMultiplexing() if (\Deployer\isVerbose()) { \Deployer\writeln(' SSH multiplexing initialization'); } - exec('ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . " 'echo \"SSH multiplexing initialization\"' "); + exec('ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . " 'echo \"SSH multiplexing initialization\"' 2>&1", $output, $returnStatus); + if ($returnStatus !== 0) { + throw new \RuntimeException(implode("\n", $output)); + } } } }