Skip to content

Commit

Permalink
[develop] Improves health checker (#171)
Browse files Browse the repository at this point in the history
* Improves `vapor:health-check` command

* Apply fixes from StyleCI

* Update VaporHealthCheckCommand.php

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
  • Loading branch information
3 people authored Jan 17, 2024
1 parent ed4f99b commit b28fbba
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Console/Commands/VaporHealthCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Laravel\Vapor\Console\Commands;

use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;

class VaporHealthCheckCommand extends Command
{
Expand Down Expand Up @@ -34,6 +37,40 @@ class VaporHealthCheckCommand extends Command
*/
public function handle()
{
$this->ensureBaseConfigurationFilesWereHarmonized();

$this->ensureCacheIsWorking();

return $this->info('Health check complete!');
}

/**
* Ensure the configuration files were harmonized.
*
* @return void
*/
protected function ensureBaseConfigurationFilesWereHarmonized()
{
if (! file_exists($filename = __DIR__.'/../../../../framework/config/cache.php')) {
return;
}

$configuration = file_get_contents($filename);

if (! Str::contains($configuration, "'key' => env('NULL_AWS_ACCESS_KEY_ID')")) {
throw new Exception(
'Laravel 11 or later requires the latest version of Vapor CLI.'
);
}
}

/**
* Ensure cache calls are working as expected.
*
* @return void
*/
protected function ensureCacheIsWorking()
{
Cache::get('vapor-health-check');
}
}

0 comments on commit b28fbba

Please sign in to comment.