move into sonardesk
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user