* Database health checks * Cache health checks * Storage write and disk-space checks * Failed queue job monitoring * Production environment diagnostics * Persisted health-check history * Queue retry controls * Scheduler execution controls * Cache and optimisation clearing * Backup creation and retention * Backup deletion * SQLite database backup support * Backup manifests and module metadata * Artisan health and backup commands * Administration navigation * Enterprise permissions * Module registration and tests
25 lines
1010 B
PHP
25 lines
1010 B
PHP
<?php
|
|
namespace Modules\Enterprise\Console;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Modules\Enterprise\Models\HealthRun;
|
|
use Modules\Enterprise\Services\SystemHealthService;
|
|
|
|
final class HealthCheckCommand extends Command
|
|
{
|
|
protected $signature = 'enterprise:health {--json}';
|
|
protected $description = 'Run enterprise platform health checks.';
|
|
|
|
public function handle(SystemHealthService $service): int
|
|
{
|
|
$result = $service->run();
|
|
HealthRun::create(['status' => $result['status'], 'results' => $result, 'ran_at' => now()]);
|
|
if ($this->option('json')) $this->line(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
else {
|
|
$this->table(['Check', 'Status', 'Message'], collect($result['checks'])->map(fn (array $check) => [$check['name'], $check['status'], $check['message']])->all());
|
|
$this->line('Overall: '.$result['status']);
|
|
}
|
|
return $result['status'] === 'failed' ? self::FAILURE : self::SUCCESS;
|
|
}
|
|
}
|