From 2739ed27e6e93e3eb474d586f4e6458f16d6ce71 Mon Sep 17 00:00:00 2001 From: Christos Sidiropoulos Date: Fri, 25 Aug 2023 12:53:44 +0000 Subject: [PATCH] Write metadata to lockfile makes it easier to debug broken proccesses - date and time - OCR Engine - mets url - page num - users ip Signed-off-by: Christos Sidiropoulos --- Classes/Plugin/FullTextGenerator.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Classes/Plugin/FullTextGenerator.php b/Classes/Plugin/FullTextGenerator.php index 49d0a3acf..79bd643ec 100644 --- a/Classes/Plugin/FullTextGenerator.php +++ b/Classes/Plugin/FullTextGenerator.php @@ -234,7 +234,15 @@ protected static function generatePageOCR(string $extKey, array $conf, Document sleep(1); session_start(); } - fopen($lockFile, "w") ; //write lock + // Get clients IP address: + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $userIP = $_SERVER['HTTP_X_FORWARDED_FOR']; + } else { + $userIP = $_SERVER['REMOTE_ADDR']; + } + $file = fopen($lockFile, "w") ; //write lock + fwrite($file, "Job: " . date("Y-m-d H:i:s T", time()) . ' | ' . $ocrEngine . ' | ' . $document->getLocation() . ' | page: ' . $pageNum. ' | users ip: ' . $userIP); //write some metadata to lock for better monitoring + fclose($file); } else { //lockfile exists -> there is already OCR running for this image, so return -> this will show the gen placeholder fulltext till the OCR is completed //TODO: give feedback to user? return;