]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6642 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 18 Jan 2024 17:44:54 +0000 (18:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 18 Jan 2024 17:44:54 +0000 (18:44 +0100)
12 files changed:
.docker/config/supervisor/default-worker.conf
.docker/config/supervisor/download-worker.conf
.docker/config/supervisor/fluidbook-process-worker.conf
.docker/config/supervisor/medialibrary-worker.conf
.docker/config/supervisor/theme-worker.conf
.docker/config/supervisor/ws2-worker.conf
app/Fluidbook/Farm.php
app/Jobs/Base.php
app/Jobs/FluidbookDocumentFileProcess.php
app/Jobs/FluidbookDocumentUpload.php
app/Models/FluidbookDocument.php
config/queue.php

index 4cd21561c20107d31d2e23d3457e2ce38eb7437e..5cfe635a0609381969805f364ac0d07cb721c0c6 100644 (file)
@@ -1,6 +1,6 @@
 [program:default-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=default --timeout=120 --max-time=3600 --memory=12000
+command=/usr/bin/php /application/artisan queue:work --queue=default --timeout=3600000 --memory=12000
 autostart=true
 autorestart=true
 user=toolbox
index 4a5f245155a71ce2526db1a3276ef3bca38f91e2..39c2f547f0ed06d5fd12c9b7a20c36b3d9625465 100644 (file)
@@ -1,6 +1,6 @@
 [program:download-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=download --timeout=7200 --max-time=3600 --memory=12000
+command=/usr/bin/php /application/artisan queue:work --queue=download --timeout=3600000 --memory=12000
 autostart=true
 autorestart=true
 user=toolbox
index 2d5633c56a3c503f1ff01c3da645da3028d1e58c..0cbb72e99d99b28590dff2f071b3bc1ba96e41b6 100644 (file)
@@ -1,6 +1,6 @@
 [program:fluidbook-process-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=fluidbookprocess --timeout=7200 --max-time=3600 --memory=12000
+command=/usr/bin/php /application/artisan queue:work --queue=fluidbookprocess --timeout=3600000 --memory=12000
 autostart=true
 autorestart=true
 user=toolbox
index 492bff15ec21c7131ce9c5efddeb5c93a043c813..2f947f093a2755bbb36ba3fd912c2a895ff25c5f 100644 (file)
@@ -1,6 +1,6 @@
 [program:medialibrary-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=medialibrary --timeout=0
+command=/usr/bin/php /application/artisan queue:work --queue=medialibrary --timeout=3600000
 autostart=true
 autorestart=true
 user=toolbox
index 793bc083d8c9dc64e75aa63fb0ae1e83cb2d7a04..b2aa670ad48ec71233a0bb710bc4a8523423d956 100644 (file)
@@ -1,6 +1,6 @@
 [program:theme-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=theme --timeout=360 --max-time=3600 --memory=12000
+command=php /application/artisan queue:work --queue=theme --timeout=3600000 --memory=12000
 autostart=true
 autorestart=true
 user=toolbox
index 3ca86be920cab0e49cc11d878722735bd0dd18e7..0beb4443660a02b96bca12ecf9d4c76ee9b74247 100644 (file)
@@ -1,6 +1,6 @@
 [program:ws2-worker]
 process_name=%(program_name)s_%(process_num)02d
-command=php /application/artisan queue:work --queue=ws2 --timeout=360 --max-time=3600 --memory=12000
+command=/usr/bin/php /application/artisan queue:work --queue=ws2 --timeout=3600000 --memory=12000
 autostart=true
 autorestart=true
 user=toolbox
index 6b69c0db5e23d5aaf30d28b4c7a04463cfd2c38f..3545088446a8c20ee1d7cc1ec4e3c943d9c35788 100644 (file)
@@ -14,8 +14,8 @@ use Mockery\Exception;
 class Farm
 {
     protected static $_outPDF = [];
-    //protected static $_forceServer = false;
-    protected static $_forceServer = 'alphaville';
+    protected static $_forceServer = false;
+    //protected static $_forceServer = 'alphaville';
 
     protected static $_region = Region::EUROPE;
 
index ce42b8a583e7adcecd86f8fffe86b3c5434af149..763688bab6f65072c879e97f2161064c0a9c1cc8 100644 (file)
@@ -18,7 +18,8 @@ class Base extends \Cubist\Backpack\Jobs\Base
     protected string $_cacheKey;
 
     public $failOnTimeout = false;
-    public $timeout = 120000;
+    public $timeout = 3600000;
+    public $retryAfter = 3600000;
 
     public function __construct()
     {
index 32ee499e9bfa1a50de4e59dc27614e88d61ab8ad..c74ee8f8cd1f5d557056ab8cb23fdcc3bf2fecf1 100644 (file)
@@ -57,9 +57,9 @@ class FluidbookDocumentFileProcess extends Base
     /**
      * @return boolean
      */
-    public function isDone($forceCheck = false)
+    public function isDone($forceCheck = false, $checkFile = true)
     {
-        return $this->finish || $this->isOK($forceCheck);
+        return $this->finish || ($checkFile && $this->isOK($forceCheck));
     }
 
     public function isOK($forceCheck = false)
index f79ee278d8d98c43fa0d4e26dd45ab26c86cfd1e..2cfe5c235f9f774a685f82b2fbab2749a5ed9a6f 100644 (file)
@@ -50,7 +50,7 @@ class FluidbookDocumentUpload extends Base
 
     public static function updateProgression($id, $document_id, $message, $progress)
     {
-        Cache::put('FluidbookDocumentUpload_' . $id, ['message' => $message, 'document' => $document_id, 'progress' => $progress]);
+        Cache::put('FluidbookDocumentUpload_' . $id, ['message' => $message, 'document' => $document_id, 'progress' => $progress, 'update' => time()]);
     }
 
     public static function getProgression($id)
index e77b97661011e4817e77e93139506af97a1455bf..83fe3a0bb4124c7daabc821c214735a7e764ff10 100644 (file)
@@ -18,6 +18,7 @@ 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
@@ -103,6 +104,8 @@ class FluidbookDocument extends ToolboxModel
             ['svg', 150, true, false, 'html'],
         ];
 
+        Log::debug('Sync ? ' . $sync);
+
         $nbfiles = count($files);
         for ($i = 1; $i <= $this->pages; $i++) {
             foreach ($files as $file) {
@@ -112,13 +115,21 @@ class FluidbookDocument extends ToolboxModel
                 } else {
                     dispatch($job);
                 }
+
                 $jobs[] = $job;
-                $this->_checkJobs($uploadID, $jobs, $nbfiles);
+                if ($sync) {
+                    $this->_checkJobs($uploadID, $jobs, $nbfiles, true);
+                }
             }
+
+            if (!$sync && $i % 4 === 0) {
+                $this->_checkJobs($uploadID, $jobs, $nbfiles, false);
+            }
+
         }
 
         while (true) {
-            if ($this->_checkJobs($uploadID, $jobs, $nbfiles) === 1) {
+            if ($this->_checkJobs($uploadID, $jobs, $nbfiles, true) === 1) {
                 return;
             }
             usleep(0.25 * 1000000);
@@ -145,14 +156,14 @@ class FluidbookDocument extends ToolboxModel
         Farm::extractLinks($this->getPDFSource(), $this->path());
     }
 
-    protected function _checkJobs($uploadID, $jobs, $nbfiles)
+    protected function _checkJobs($uploadID, $jobs, $nbfiles, $checkFile = true)
     {
         $this->checkInfos();
         $nbjobs = $nbfiles * $this->pages;
         $done = 0;
         foreach ($jobs as $job) {
             /** @var $job FluidbookDocumentFileProcess */
-            if ($job->isDone()) {
+            if ($job->isDone(false, $checkFile)) {
                 $done++;
             }
         }
@@ -169,6 +180,7 @@ class FluidbookDocument extends ToolboxModel
     public function checkInfos($force = false)
     {
         if ($force || null === $this->pdf_data) {
+            Log::debug('check document infos');
             $infos = $this->_getInfos();
 
             $this->pages = $infos->pages;
@@ -305,31 +317,30 @@ class FluidbookDocument extends ToolboxModel
     public function _getPath($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')
     {
         $this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version);
-        $cacheKey = $this->fileCacheKey($page, $format, $resolution, $quality, $withText, $withGraphics, $version);
-        if (Cache::has($cacheKey)) {
-            return Cache::get($cacheKey);
-        }
+        $cacheKey = $this->fileCacheKey($page, $format, $resolution, $quality, $withText, $withGraphics, $version) . '_path';
 
-        $dir = $this->path($version) . '/';
+        return Cache::rememberForever($cacheKey, function () use ($page, $format, $resolution, $quality, $withText, $withGraphics, $version) {
+            $dir = $this->path($version) . '/';
 
-        if ($format === 'svg') {
-            $prefix = $withGraphics ? 'f' : 't';
-            $file = $dir . $prefix . 'o' . $page;
-            if ($withGraphics) {
-                $file .= '-' . $resolution;
-            }
-            $file .= '.svg';
-        } else {
-            $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
-            $prefix = $withText ? 't' : 'h';
-            if ($resolution === 'thumb') {
-                $file = $dir . 'p' . $page . $q . '.' . $format;
+            if ($format === 'svg') {
+                $prefix = $withGraphics ? 'f' : 't';
+                $file = $dir . $prefix . 'o' . $page;
+                if ($withGraphics) {
+                    $file .= '-' . $resolution;
+                }
+                $file .= '.svg';
             } else {
-                $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
+                $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
+                $prefix = $withText ? 't' : 'h';
+                if ($resolution === 'thumb') {
+                    $file = $dir . 'p' . $page . $q . '.' . $format;
+                } else {
+                    $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
+                }
             }
-        }
 
-        return $file;
+            return $file;
+        });
     }
 
     protected function fileCacheKey($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')
index 5a0356205aa806c96c47506e0c4764b112fef993..fad4222a1429d9bef059ff28dbfb6e1f005afa5b 100644 (file)
@@ -39,14 +39,15 @@ return [
             'table' => 'jobs',
             'queue' => 'default',
             'after_commit' => true,
-            'retry_after' => 90,
+            'retry_after' => 3600000,
+            'timeout' => 3600000,
         ],
 
         'beanstalkd' => [
             'driver' => 'beanstalkd',
             'host' => 'localhost',
             'queue' => 'default',
-            'retry_after' => 90,
+            'retry_after' => 3600000,
             'block_for' => 0,
         ],
 
@@ -63,7 +64,7 @@ return [
             'driver' => 'redis',
             'connection' => 'default',
             'queue' => env('REDIS_QUEUE', 'default'),
-            'retry_after' => 90,
+            'retry_after' => 3600000,
             'block_for' => null,
         ],