Skip to content

Commit ca83af1

Browse files
authored
Merge pull request #430 from magento-thunder/MAGECLOUD-2895
MAGECLOUD-3246: Add --use-rewrites option to install command, MAGECLOUD-2895: The var/log/install_upgrade.log is useless without dividers and timestamps
2 parents ef43872 + cf91199 commit ca83af1

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

src/Process/Deploy/InstallUpdate/Install/Setup.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ public function execute()
112112
}
113113

114114
try {
115+
$installUpgradeLog = $this->fileList->getInstallUpgradeLog();
116+
117+
$this->shell->execute('echo \'Installation time: \'$(date) | tee -a ' . $installUpgradeLog);
115118
$this->shell->execute(sprintf(
116119
'/bin/bash -c "set -o pipefail; %s | tee -a %s"',
117120
escapeshellcmd($command),
118-
$this->fileList->getInstallUpgradeLog()
121+
$installUpgradeLog
119122
));
120123
} catch (ShellException $exception) {
121124
throw new ProcessException($exception->getMessage(), $exception->getCode(), $exception);
@@ -143,7 +146,7 @@ private function getBaseCommand(): string
143146
. ' --backend-frontname=' . escapeshellarg($this->environment->getAdminUrl()
144147
?: Environment::DEFAULT_ADMIN_URL)
145148
. ($this->environment->getAdminEmail() ? $this->getAdminCredentials() : '')
146-
. ' --use-secure-admin=1 --ansi --no-interaction';
149+
. ' --use-secure-admin=1 --use-rewrites=1 --ansi --no-interaction';
147150
}
148151

149152
/**

src/Process/Deploy/InstallUpdate/Update/Setup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ public function execute()
9393

9494
try {
9595
$verbosityLevel = $this->stageConfig->get(DeployInterface::VAR_VERBOSE_COMMANDS);
96+
$installUpgradeLog = $this->fileList->getInstallUpgradeLog();
9697

9798
$this->logger->info('Running setup upgrade.');
9899

100+
$this->shell->execute('echo \'Updating time: \'$(date) | tee -a ' . $installUpgradeLog);
99101
$this->shell->execute(sprintf(
100102
'/bin/bash -c "set -o pipefail; %s | tee -a %s"',
101103
'php ./bin/magento setup:upgrade --keep-generated --ansi --no-interaction ' . $verbosityLevel,
102-
$this->fileList->getInstallUpgradeLog()
104+
$installUpgradeLog
103105
));
104106
} catch (\RuntimeException $exception) {
105107
//Rollback required by database

src/Test/Unit/Process/Deploy/InstallUpdate/Install/SetupTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,19 @@ public function testExecute(
184184
. ' --admin-firstname=\'' . $adminFirstnameExpected . '\' --admin-lastname=\'' . $adminLastnameExpected
185185
. '\' --admin-email=\'' . $adminEmail . '\' --admin-password=\'' . $adminPasswordExpected . '\''
186186
: '';
187-
$this->shellMock->expects($this->once())
187+
$this->shellMock->expects($this->exactly(2))
188188
->method('execute')
189-
->with(
190-
'/bin/bash -c "set -o pipefail;'
189+
->withConsecutive(
190+
['echo \'Installation time: \'$(date) | tee -a ' . $installUpgradeLog],
191+
['/bin/bash -c "set -o pipefail;'
191192
. ' php ./bin/magento setup:install -n --session-save=db --cleanup-database --currency=\'USD\''
192193
. ' --base-url=\'http://unsecure.url\' --base-url-secure=\'https://secure.url\' --language=\'fr_FR\''
193194
. ' --timezone=America/Los_Angeles --db-host=\'localhost\' --db-name=\'magento\' --db-user=\'user\''
194195
. ' --backend-frontname=\'' . $adminUrlExpected . '\''
195196
. $adminCredential
196-
. ' --use-secure-admin=1 --ansi --no-interaction'
197+
. ' --use-secure-admin=1 --use-rewrites=1 --ansi --no-interaction'
197198
. ' --db-password=\'password\' -v'
198-
. ' | tee -a ' . $installUpgradeLog . '"'
199+
. ' | tee -a ' . $installUpgradeLog . '"']
199200
);
200201

201202
$this->process->execute();

src/Test/Unit/Process/Deploy/InstallUpdate/Update/SetupTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ public function testExecute()
105105
$this->flagManagerMock->expects($this->exactly(2))
106106
->method('delete')
107107
->with(FlagManager::FLAG_REGENERATE);
108-
$this->shellMock->expects($this->once())
108+
$this->shellMock->expects($this->exactly(2))
109109
->method('execute')
110-
->with(
111-
'/bin/bash -c "set -o pipefail; php ./bin/magento setup:upgrade '
110+
->withConsecutive(
111+
['echo \'Updating time: \'$(date) | tee -a ' . $installUpgradeLog],
112+
['/bin/bash -c "set -o pipefail; php ./bin/magento setup:upgrade '
112113
. '--keep-generated --ansi --no-interaction -v | tee -a '
113-
. $installUpgradeLog . '"'
114+
. $installUpgradeLog . '"']
114115
);
115116
$this->loggerMock->expects($this->once())
116117
->method('info')

0 commit comments

Comments
 (0)