Browse Source

CHG: FindBox Service, now retry to connect to findbox core if no connection

Giancarlo 8 years ago
parent
commit
a60a108f82
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/OpenMind/FindBox/FindBoxService.php

+ 11 - 3
src/OpenMind/FindBox/FindBoxService.php

@@ -15,14 +15,22 @@ class FindBoxService
 {
   /** @var SQL $dbHandle */
   private $dbHandle;
-  private $findBoxCore;
+  private $findBoxCore = null;
   private $labelToBlink;
 
   public function __construct()
   {
     global $f3;
     $this->dbHandle = $f3->get('DB');
-    $this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
+    while ($this->findBoxCore == null)
+      try {
+        $this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
+      } catch (\Exception $e) {
+        echo $this->getStrTime() . "Can't find FindBoxCore, retry in 1 second..\n";
+        ob_flush();
+        flush();
+        sleep(1);
+      }
     $this->labelToBlink = [];
   }
 
@@ -112,7 +120,7 @@ class FindBoxService
       $this->getCurrentQueue();
 
       //echo $this->getStrTime() . 'Label in cache: ' . count($this->labelToBlink) . "     \n";
-      foreach($this->labelToBlink as $labelId => $label) {
+      foreach ($this->labelToBlink as $labelId => $label) {
 
         // Priority 1
         // ----------