Skip to content

A free open source IT asset/license management system

Fixed #18600 - add filesystem check on health checker

snipe1f26bf11257f
diff --git a/app/Http/Controllers/HealthController.php b/app/Http/Controllers/HealthController.php
index dac1f17bf4..5f90b8ba6f 100644
--- a/app/Http/Controllers/HealthController.php
+++ b/app/Http/Controllers/HealthController.php
@@ -28,23 +28,34 @@ class HealthController extends BaseController
*/
public function get()
{
- try {
- if (DB::select('select 2 + 2')) {
- return response()->json([
- 'status' => 'ok',
- ]);
- }
+ if (DB::select('select 2 + 2')) {
+ $db_status = 'ok';
+ } else {
+ $db_status = 'could not connect to database';
+ }
+
- } catch (\Exception $e) {
- \Log::error('Could not connect to database');
+ if (is_writable(storage_path('logs'))) {
+ $filesystem_status = 'ok';
+ } else {
+ $filesystem_status = 'Could not write to storage/logs';
+ }
+
+ if (($filesystem_status!='ok') || ($db_status!='ok')) {
return response()->json([
- 'status' => 'database connection failed',
+ 'status' =>
+ [
+ 'database' => $db_status,
+ 'filesystem' => $filesystem_status,
+ ]
], 500);
-
}
+ return response()->json([
+ 'status' => 'ok',
+ ]);
}
}