Skip to content

Commit

Permalink
Write metadata to lockfile
Browse files Browse the repository at this point in the history
makes it easier to debug broken proccesses

 - date and time
 - OCR Engine
 - mets url
 - page num
 - users ip

Signed-off-by: Christos Sidiropoulos <[email protected]>
  • Loading branch information
csidirop committed Aug 25, 2023
1 parent 2c2b049 commit 2739ed2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Classes/Plugin/FullTextGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2739ed2

Please sign in to comment.