mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 23:44:30 -04:00
Merge pull request #9762 from hillelcoren/v5-develop
Add queue stats to the health check stats
This commit is contained in:
commit
d8205528c8
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace App\Utils;
|
namespace App\Utils;
|
||||||
|
|
||||||
|
use LimitIterator;
|
||||||
|
use SplFileObject;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Mail\TestMailServer;
|
use App\Mail\TestMailServer;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -78,9 +80,9 @@ class SystemHealth
|
|||||||
'open_basedir' => (bool) self::checkOpenBaseDir(),
|
'open_basedir' => (bool) self::checkOpenBaseDir(),
|
||||||
'mail_mailer' => (string) self::checkMailMailer(),
|
'mail_mailer' => (string) self::checkMailMailer(),
|
||||||
'flutter_renderer' => (string) config('ninja.flutter_canvas_kit'),
|
'flutter_renderer' => (string) config('ninja.flutter_canvas_kit'),
|
||||||
'jobs_pending' => (int) self::checkQueueSize(),
|
|
||||||
'pdf_engine' => (string) self::getPdfEngine(),
|
'pdf_engine' => (string) self::getPdfEngine(),
|
||||||
'queue' => (string) config('queue.default'),
|
'queue' => (string) config('queue.default'),
|
||||||
|
'queue_data' => self::checkQueueData(),
|
||||||
'trailing_slash' => (bool) self::checkUrlState(),
|
'trailing_slash' => (bool) self::checkUrlState(),
|
||||||
'file_permissions' => (string) ($check_file_system ? self::checkFileSystem() : ''),
|
'file_permissions' => (string) ($check_file_system ? self::checkFileSystem() : ''),
|
||||||
'exchange_rate_api_not_configured' => (bool)self::checkCurrencySanity(),
|
'exchange_rate_api_not_configured' => (bool)self::checkCurrencySanity(),
|
||||||
@ -117,16 +119,28 @@ class SystemHealth
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function checkQueueSize()
|
private static function checkQueueData()
|
||||||
{
|
{
|
||||||
$count = 0;
|
$pending = 0;
|
||||||
|
$failed = 0;
|
||||||
|
$last_error = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$count = Queue::size();
|
$pending = DB::table('jobs')->count();
|
||||||
|
$failed = DB::table('failed_jobs')->count();
|
||||||
|
|
||||||
|
if ($failed > 0) {
|
||||||
|
$failed_job = DB::table('failed_jobs')->latest('failed_at')->first();
|
||||||
|
$last_error = $failed_job->exception;
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $count;
|
return [
|
||||||
|
'failed' => $failed,
|
||||||
|
'pending' => $pending,
|
||||||
|
'last_error' => $last_error,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkFileSystem()
|
public static function checkFileSystem()
|
||||||
@ -325,11 +339,12 @@ class SystemHealth
|
|||||||
|
|
||||||
public static function lastError()
|
public static function lastError()
|
||||||
{
|
{
|
||||||
$filepath = storage_path('logs/laravel.log');
|
$log_file = new SplFileObject(sprintf('%s/laravel.log', base_path('storage/logs')));
|
||||||
$file = escapeshellarg($filepath);
|
$log_file->seek(PHP_INT_MAX);
|
||||||
$end_of_file = `tail -n 500 $file`;
|
$last_line = $log_file->key();
|
||||||
|
|
||||||
$lines = explode("\n", $end_of_file);
|
$lines = new LimitIterator($log_file, max(0, $last_line - 500), $last_line);
|
||||||
|
$log_lines = iterator_to_array($lines);
|
||||||
$last_error = '';
|
$last_error = '';
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user