mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 01:02:24 +01:00
Better tty
This commit is contained in:
parent
df21fa16ea
commit
ace288978c
@ -14,6 +14,9 @@ task('deploy:update_code', function () {
|
||||
$git = get('bin/git');
|
||||
$gitCache = get('git_cache');
|
||||
$depth = $gitCache ? '' : '--depth 1';
|
||||
$options = [
|
||||
'tty' => get('git_tty', false),
|
||||
];
|
||||
|
||||
// If option `branch` is set.
|
||||
if (input()->hasOption('branch')) {
|
||||
@ -49,14 +52,14 @@ task('deploy:update_code', function () {
|
||||
|
||||
if ($gitCache && isset($releases[1])) {
|
||||
try {
|
||||
run("$git clone $at --recursive -q --reference {{deploy_path}}/releases/{$releases[1]} --dissociate $repository {{release_path}} 2>&1");
|
||||
run("$git clone $at --recursive -q --reference {{deploy_path}}/releases/{$releases[1]} --dissociate $repository {{release_path}} 2>&1", $options);
|
||||
} catch (\RuntimeException $exc) {
|
||||
// If {{deploy_path}}/releases/{$releases[1]} has a failed git clone, is empty, shallow etc, git would throw error and give up. So we're forcing it to act without reference in this situation
|
||||
run("$git clone $at --recursive -q $repository {{release_path}} 2>&1");
|
||||
run("$git clone $at --recursive -q $repository {{release_path}} 2>&1", $options);
|
||||
}
|
||||
} else {
|
||||
// if we're using git cache this would be identical to above code in catch - full clone. If not, it would create shallow clone.
|
||||
run("$git clone $at $depth --recursive -q $repository {{release_path}} 2>&1");
|
||||
run("$git clone $at $depth --recursive -q $repository {{release_path}} 2>&1", $options);
|
||||
}
|
||||
|
||||
if (!empty($revision)) {
|
||||
|
@ -47,12 +47,24 @@ class Client
|
||||
|
||||
$options = $host->sshOptions();
|
||||
|
||||
if ($host->isMultiplexing()) {
|
||||
$options = $this->initMultiplexing($host);
|
||||
}
|
||||
|
||||
// When tty need to be allocated, don't use multiplexing,
|
||||
// and pass command without bash allocation on remote host.
|
||||
if ($config['tty']) {
|
||||
$options .= ' -tt';
|
||||
$command = escapeshellarg($command);
|
||||
|
||||
$ssh = "ssh $options $host $command";
|
||||
$process = new Process($ssh);
|
||||
$process
|
||||
->setTimeout($config['timeout'])
|
||||
->setTty(true)
|
||||
->mustRun();
|
||||
|
||||
return $process->getOutput();
|
||||
}
|
||||
|
||||
if ($host->isMultiplexing()) {
|
||||
$options = $this->initMultiplexing($host);
|
||||
}
|
||||
|
||||
$ssh = "ssh $options $host 'bash -s; printf \"[exit_code:%s]\" $?;'";
|
||||
@ -112,13 +124,17 @@ class Client
|
||||
|
||||
private function filterOutput($output)
|
||||
{
|
||||
return preg_replace('/\[exit_code:(.*?)\]$/', '', $output);
|
||||
return preg_replace('/\[exit_code:(.*?)\]/', '', $output);
|
||||
}
|
||||
|
||||
private function parseExitStatus(Process $process)
|
||||
{
|
||||
$output = $process->getOutput();
|
||||
preg_match('/\[exit_code:(.*?)\]$/', $output, $match);
|
||||
preg_match('/\[exit_code:(.*?)\]/', $output, $match);
|
||||
|
||||
if (!isset($match[1])) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$exitCode = (int)$match[1];
|
||||
return $exitCode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user