8d41f473e4
移除 php_version、laravel、environment、memory_mb, 保留 status、timestamp、checks 三欄。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
907 B
PHP
37 lines
907 B
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::get('/health', function () {
|
|
$checks = ['db' => false, 'redis' => false, 'cache' => false];
|
|
|
|
try {
|
|
DB::connection()->getPdo();
|
|
$checks['db'] = true;
|
|
} catch (\Throwable) {}
|
|
|
|
try {
|
|
Redis::ping();
|
|
$checks['redis'] = true;
|
|
} catch (\Throwable) {}
|
|
|
|
try {
|
|
cache()->put('health_check', 'ok', 5);
|
|
$checks['cache'] = cache()->get('health_check') === 'ok';
|
|
} catch (\Throwable) {}
|
|
|
|
$healthy = $checks['db'] && $checks['redis'] && $checks['cache'];
|
|
|
|
return response()->json([
|
|
'status' => $healthy ? 'ok' : 'degraded',
|
|
'timestamp' => now()->toIso8601String(),
|
|
'checks' => $checks,
|
|
], $healthy ? 200 : 503);
|
|
});
|
|
|
|
Route::get('/', function () {
|
|
return view('welcome');
|
|
});
|