Skip to content

Commit

Permalink
Fix ssh master connection opening
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed May 10, 2017
1 parent 51b644d commit 7c312bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## master
[v5.0.0-beta.2...master](https://github.com/deployphp/deployer/compare/v5.0.0-beta.2...master)

-
### Fixed
- Fixed ssh multiplexing master connection initializing

## v5.0.0-beta.3
[v5.0.0-beta.2...v5.0.0-beta.3](https://github.com/deployphp/deployer/compare/v5.0.0-beta.2...v5.0.0-beta.3)
Expand Down
12 changes: 9 additions & 3 deletions src/Ssh/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,22 @@ private function parseExitStatus(Process $process)
return $exitCode;
}

private function initMultiplexing(Host $host) : Arguments
private function initMultiplexing(Host $host)
{
$sshArguments = $host->getSshArguments()->withMultiplexing($host);
$controlPath = $sshArguments->getOption('ControlPath');

$process = new Process("ssh $sshArguments -O check -S $controlPath $host 2>&1");
$process = new Process("ssh -O check $sshArguments $host 2>&1");
$process->run();

if (!preg_match('/Master running/', $process->getOutput()) && $this->output->isVeryVerbose()) {
$this->pop->writeln(Process::OUT, $host->getHostname(), 'ssh multiplexing initialization');

// Open master connection explicit,
// ControlMaster=auto could not working
(new Process("ssh -M $sshArguments $host"))->start();

// Delay to wait connection established
sleep(1);

This comment has been minimized.

Copy link
@staabm

staabm May 10, 2017

Contributor

Process->run() is synchronous. we dont need the sleep when using run instead of start

This comment has been minimized.

Copy link
@antonmedv

antonmedv May 10, 2017

Author Member

In come cases master connection wont go to background and run() waits until timeout (ControlPersist=60).
So start() and don't wait here. But connection may not be established on next ssh call, so we need to wait here before.

}

return $sshArguments;
Expand Down

0 comments on commit 7c312bf

Please sign in to comment.