| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/switchyard/current/app/Http/Controllers/Api/ |
Upload File : |
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Throwable;
class HealthController extends Controller
{
public function __invoke(): JsonResponse
{
$checks = [
'db' => $this->checkDb(),
'redis' => $this->checkRedis(),
];
$healthy = ! in_array(false, array_column($checks, 'ok'), true);
return response()
->json([
'healthy' => $healthy,
'version' => config('app.version', '0.1.0'),
'checks' => $checks,
], $healthy ? 200 : 503);
}
private function checkDb(): array
{
try {
DB::connection()->getPdo();
return ['ok' => true];
} catch (Throwable $e) {
return ['ok' => false, 'error' => $e->getMessage()];
}
}
private function checkRedis(): array
{
try {
Redis::ping();
return ['ok' => true];
} catch (Throwable $e) {
return ['ok' => false, 'error' => $e->getMessage()];
}
}
}