From 36d999dabc475f1f2f5eee22f6fb616635b58c5f Mon Sep 17 00:00:00 2001 From: Julien Galletta Date: Thu, 7 Dec 2017 11:19:08 +0100 Subject: [PATCH 1/3] Add option to configure timeout for tar operations. --- src/Task/BuiltIn/Deploy/Tar/CopyTask.php | 3 ++- src/Task/BuiltIn/Deploy/Tar/PrepareTask.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php index 294d2bc..314ae26 100644 --- a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php @@ -45,6 +45,7 @@ class CopyTask extends AbstractTask $tarPath = $this->runtime->getEnvOption('tar_extract_path', 'tar'); $flags = $this->runtime->getEnvOption('tar_extract', 'xfzop'); + $timeout = $this->runtime->getEnvOption('tar_timeout', 600); $targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId); $tarLocal = $this->runtime->getVar('tar_local'); @@ -56,7 +57,7 @@ class CopyTask extends AbstractTask $process = $this->runtime->runLocalCommand($cmdCopy, 300); if ($process->isSuccessful()) { $cmdUnTar = sprintf('cd %s && %s %s %s', $targetDir, $tarPath, $flags, $tarRemote); - $process = $this->runtime->runRemoteCommand($cmdUnTar, false, 600); + $process = $this->runtime->runRemoteCommand($cmdUnTar, false, $timeout); if ($process->isSuccessful()) { $cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote); $process = $this->runtime->runRemoteCommand($cmdDelete, false); diff --git a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php index 9db8486..d872591 100644 --- a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php @@ -43,11 +43,12 @@ class PrepareTask extends AbstractTask $excludes = $this->getExcludes(); $tarPath = $this->runtime->getEnvOption('tar_create_path', 'tar'); $flags = $this->runtime->getEnvOption('tar_create', 'cfzp'); + $timeout = $this->runtime->getEnvOption('tar_timeout', 300); $from = $this->runtime->getEnvOption('from', './'); $cmdTar = sprintf('%s %s %s %s %s', $tarPath, $flags, $tarLocal, $excludes, $from); /** @var Process $process */ - $process = $this->runtime->runLocalCommand($cmdTar, 300); + $process = $this->runtime->runLocalCommand($cmdTar, $timeout); return $process->isSuccessful(); } From 8baa1a01fd7b0ebfd300a4e1042fe2a59295e381 Mon Sep 17 00:00:00 2001 From: Julien Galletta Date: Thu, 7 Dec 2017 13:33:46 +0100 Subject: [PATCH 2/3] Make configurable tar timeout also impact the scp command from Tar/CopyTask. --- src/Task/BuiltIn/Deploy/Tar/CopyTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php index 314ae26..3bb5f77 100644 --- a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php @@ -45,7 +45,7 @@ class CopyTask extends AbstractTask $tarPath = $this->runtime->getEnvOption('tar_extract_path', 'tar'); $flags = $this->runtime->getEnvOption('tar_extract', 'xfzop'); - $timeout = $this->runtime->getEnvOption('tar_timeout', 600); + $timeout = $this->runtime->getEnvOption('tar_timeout', 300); $targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId); $tarLocal = $this->runtime->getVar('tar_local'); @@ -54,10 +54,10 @@ class CopyTask extends AbstractTask $cmdCopy = sprintf('scp -P %d %s %s %s@%s:%s/%s', $sshConfig['port'], $sshConfig['flags'], $tarLocal, $user, $host, $targetDir, $tarRemote); /** @var Process $process */ - $process = $this->runtime->runLocalCommand($cmdCopy, 300); + $process = $this->runtime->runLocalCommand($cmdCopy, $timeout); if ($process->isSuccessful()) { $cmdUnTar = sprintf('cd %s && %s %s %s', $targetDir, $tarPath, $flags, $tarRemote); - $process = $this->runtime->runRemoteCommand($cmdUnTar, false, $timeout); + $process = $this->runtime->runRemoteCommand($cmdUnTar, false, $timeout + 300); if ($process->isSuccessful()) { $cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote); $process = $this->runtime->runRemoteCommand($cmdDelete, false); From 612e71e4510c84677c2bd9aa0a674d28c1b4dc18 Mon Sep 17 00:00:00 2001 From: Julien Galletta Date: Tue, 12 Dec 2017 13:28:21 +0100 Subject: [PATCH 3/3] Double timeout for tar archive scp copy instead of adding +300s. --- src/Task/BuiltIn/Deploy/Tar/CopyTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php index 3bb5f77..4149223 100644 --- a/src/Task/BuiltIn/Deploy/Tar/CopyTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/CopyTask.php @@ -57,7 +57,7 @@ class CopyTask extends AbstractTask $process = $this->runtime->runLocalCommand($cmdCopy, $timeout); if ($process->isSuccessful()) { $cmdUnTar = sprintf('cd %s && %s %s %s', $targetDir, $tarPath, $flags, $tarRemote); - $process = $this->runtime->runRemoteCommand($cmdUnTar, false, $timeout + 300); + $process = $this->runtime->runRemoteCommand($cmdUnTar, false, $timeout * 2); if ($process->isSuccessful()) { $cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote); $process = $this->runtime->runRemoteCommand($cmdDelete, false);