From: Vincent Vanwaelscappel Date: Mon, 8 Jan 2024 17:35:40 +0000 (+0100) Subject: wip #6615 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7a1dff082ef1a06ac49e7f6f2859ddab3bbccadc;p=fluidbook-toolbox.git wip #6615 @1.5 --- diff --git a/.docker/update.sh b/.docker/update.sh index 87d084c36..b25744609 100644 --- a/.docker/update.sh +++ b/.docker/update.sh @@ -3,6 +3,7 @@ cd /docker/fluidbook-toolbox docker plugin install ucphhpc/sshfs --grant-all-permissions /home/toolbox/www/scripts/fixrights.sh chown root:root /home/toolbox/www/.docker/config/cron/host;ln -sf /home/toolbox/www/.docker/config/cron/host /etc/cron.d/toolbox +chown root:root /home/toolbox/www/.docker/config/sudoers docker network create fluidbook-toolbox docker compose down docker volume rm fluidbook-toolbox_sshfsusstorage diff --git a/app/Fluidbook/Farm.php b/app/Fluidbook/Farm.php index 43755b5f6..aa29d8ed6 100644 --- a/app/Fluidbook/Farm.php +++ b/app/Fluidbook/Farm.php @@ -2,7 +2,6 @@ namespace App\Fluidbook; -use Cubist\PDF\PDFTools; use Cubist\Util\Files\Files; use Fluidbook\Tools\Jobs\ProcessFile; use hollodotme\FastCGI\Client; @@ -117,6 +116,9 @@ class Farm return trim($response->getBody()); } + /** + * @throws \Exception + */ public static function getFile($page, $format, $resolution, $quality, $withText, $withGraphics, $version, $resolutionRatio, $mobileFirstRatio, $path, $force = false) { $params = [ @@ -322,6 +324,14 @@ class Farm $time = round(microtime(true) - $start, 4); $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t" . $time . "\t" . implode('|', $params) . "\t($res)\t>>" . $output . "\n"; + $dir = isset($params['pdf']) ? dirname($params['pdf']) : $params['out']; + $logfile = $dir . '/farm.log'; + + if ($fp = fopen($logfile, 'ab')) { + fwrite($fp, $log); + fclose($fp); + } + if (!$res) { if ($attempts > 0) { Log::warning('Farm failure (' . $farmer['name'] . ') : ' . $output . ' // ' . $log); diff --git a/app/Jobs/FluidbookDocumentFileProcess.php b/app/Jobs/FluidbookDocumentFileProcess.php index 5db7f88d3..32ee499e9 100644 --- a/app/Jobs/FluidbookDocumentFileProcess.php +++ b/app/Jobs/FluidbookDocumentFileProcess.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\FluidbookDocument; +use Illuminate\Support\Facades\Log; class FluidbookDocumentFileProcess extends Base { @@ -47,6 +48,7 @@ class FluidbookDocumentFileProcess extends Base try { echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n"; } catch (\Exception $e) { + Log::warning($e->getMessage()); $this->log = $e->getMessage(); } $this->finish = true; @@ -78,7 +80,8 @@ class FluidbookDocumentFileProcess extends Base return $this->path; } - public function getLog(){ + public function getLog() + { return $this->log; } } diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index f3cf142a1..12e2df004 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -18,7 +18,6 @@ use Cubist\Util\Files\Files; use Cubist\Util\Gzip; use Cubist\Util\Math; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Log; // __('!!Paramètres des fluidbooks') class FluidbookDocument extends ToolboxModel @@ -371,6 +370,9 @@ class FluidbookDocument extends ToolboxModel } + /** + * @throws \Exception + */ public function _getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = true) { Farm::setRegion($this->getRegion()); diff --git a/scripts/fixrights.sh b/scripts/fixrights.sh index 4d1ecece7..bda2abda4 100644 --- a/scripts/fixrights.sh +++ b/scripts/fixrights.sh @@ -7,8 +7,11 @@ chmod -R 775 /home/toolbox/www/public chmod -R 775 /home/toolbox/www/bin chown root:root /home/toolbox/dev/.docker/config/sudoers +chown root:root /home/toolbox/dev/.docker/config/cron/host chmod -R 775 /home/toolbox/dev/scripts chmod -R 775 /home/toolbox/dev/protected chmod -R 775 /home/toolbox/dev/public chmod -R 775 /home/toolbox/dev/bin +chown root:root /home/toolbox/alpha/.docker/config/sudoers +chown root:root /home/toolbox/alpha/.docker/config/cron/host