Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOPS-2119 - Wait for a healthcheck before releasing the command #2564

Merged
merged 11 commits into from
Apr 9, 2024
11 changes: 10 additions & 1 deletion src/Commands/Site/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ public function create($site_name, $label, $upstream_id, $options = ['org' => nu
if ($site = $this->getSiteById($workflow->get('waiting_for_task')->site_id)) {
$this->log()->notice('Deploying CMS...');
$this->processWorkflow($site->deployProduct($upstream->id));
$this->log()->notice('Deployed CMS');
$this->log()->notice('Waiting for site availability...');
$waits = 0;
do {
sleep(5);
$woke = $site->getEnvironments()->get('dev')->wake();
// if success is empty, then the site is still waking up.
$waits++;
stovak marked this conversation as resolved.
Show resolved Hide resolved
// If we've waited more than 25 seconds, then something is wrong.
} while (($woke['success'] ?? false) !== true || $waits < 5);
$this->log()->notice('Your site has been created successfully!');
stovak marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
6 changes: 3 additions & 3 deletions src/Models/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use Pantheon\Terminus\Collections\Domains;
use Pantheon\Terminus\Collections\EnvironmentMetrics;
use Pantheon\Terminus\Collections\Workflows;
use Pantheon\Terminus\Helpers\LocalMachineHelper;
use Pantheon\Terminus\Exceptions\TerminusException;
use Pantheon\Terminus\Friends\SiteInterface;
use Pantheon\Terminus\Friends\SiteTrait;
use Pantheon\Terminus\Exceptions\TerminusException;
use Pantheon\Terminus\Helpers\LocalMachineHelper;

/**
* Class Environment
Expand Down Expand Up @@ -1000,7 +1000,7 @@ public function sftpConnectionInfo()
*
* @return array
*/
public function wake()
public function wake(): array
{
$domains = array_filter(
$this->getDomains()->all(),
Expand Down
Loading