Browse Source

Merge pull request #177 from MovingImage24/connect_timeout

Add config option to set ConnectTimeout for ssh connections
1.0
Andrés Montañez 10 years ago
parent
commit
2baf8f3d44
  1. 10
      Mage/Config.php
  2. 1
      Mage/Task/AbstractTask.php
  3. 2
      Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php

10
Mage/Config.php

@ -391,6 +391,16 @@ class Config
return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : ''; return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : '';
} }
/**
* Get the ConnectTimeout option
*
* @return string
*/
public function getConnectTimeoutOption()
{
return $this->environmentConfig('connect-timeout') ? ('-o ConnectTimeout=' . $this->environmentConfig('connect-timeout') . ' ') : '';
}
/** /**
* Get the current Host * Get the current Host
* *

1
Mage/Task/AbstractTask.php

@ -201,6 +201,7 @@ abstract class AbstractTask
$localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' ' $localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
. '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
. $this->getConfig()->getConnectTimeoutOption()
. $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName(); . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName();
$remoteCommand = str_replace('"', '\"', $command); $remoteCommand = str_replace('"', '\"', $command);

2
Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php

@ -89,7 +89,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
} }
// Copy Tar Gz to Remote Host // Copy Tar Gz to Remote Host
$command = 'scp ' . $strategyFlags . ' ' . $this->getConfig()->getHostIdentityFileOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz ' $command = 'scp ' . $strategyFlags . ' ' . $this->getConfig()->getHostIdentityFileOption() . $this->getConfig()->getConnectTimeoutOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz '
. $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory; . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
$result = $this->runCommandLocal($command) && $result; $result = $this->runCommandLocal($command) && $result;

Loading…
Cancel
Save