Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/Commands/Deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$startTime = time();
// A deployment can wait for another one of the same environment before it starts:
// the timeout only counts from the moment it no longer waits
$timeout = 15 * 60;
$deadline = time() + $timeout;
$deployLogs = [];
$spinnerMessage = null;

// Timeout after 15 minutes
while (time() - $startTime < 15 * 60) {
while (time() < $deadline) {
$deployment = $brefCloud->getDeployment($deploymentId);

if ($deployment['status'] === 'deploying') {
if ($deployment['message'] === 'waiting') {
$deadline = time() + $timeout;
}
// E.g. "waiting" while another deployment of the environment runs
if ($deployment['message'] !== $spinnerMessage) {
$spinnerMessage = $deployment['message'];
IO::spin($spinnerMessage);
}
}

// Logs
if (! $isServerlessFrameworkDeploy) {
// Diff between all the deployment logs and the ones we already know about
Expand All @@ -160,6 +174,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
IO::spinSuccess($deployment['message'], $deployment['app_url'] ?? null);
return 0;
}
// Superseded by a newer deployment of the environment, which is not an error
if ($deployment['status'] === 'canceled') {
IO::spinSuccess($deployment['message']);
IO::writeln([
Styles::gray($deployment['error_message'] ?? 'The deployment was canceled'),
'',
Styles::gray('Deployment logs: ' . $deployment['url']),
]);
return 0;
}
if ($deployment['status'] === 'failed') {
IO::spinError($deployment['message']);
IO::writeln([
Expand Down
Loading