]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Thu, 29 Aug 2019 07:43:03 +0000 (09:43 +0200)
committerVincent <vincent@enhydra.fr>
Thu, 29 Aug 2019 07:43:03 +0000 (09:43 +0200)
.idea/workspace.xml
scripts/lib/ssh.php
servers/insteon.php
servers/squeezebox.php

index 2373f87458c448dd6ccb7d354722d5da7fe9043b..a7dc4aca608966ed47925eece06a09d17dfa633b 100644 (file)
@@ -3,6 +3,9 @@
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/ssh.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/ssh.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/servers/insteon.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/insteon.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/servers/squeezebox.php" beforeDir="false" afterPath="$PROJECT_DIR$/servers/squeezebox.php" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1566643527124" duration="3756000" />
       <workItem from="1566649679962" duration="18000" />
       <workItem from="1566649714025" duration="13165000" />
-    </task>
-    <task id="LOCAL-00168" summary=".">
-      <created>1551170339955</created>
-      <option name="number" value="00168" />
-      <option name="presentableId" value="LOCAL-00168" />
-      <option name="project" value="LOCAL" />
-      <updated>1551170339955</updated>
+      <workItem from="1567019099272" duration="183000" />
+      <workItem from="1567019296675" duration="3128000" />
     </task>
     <task id="LOCAL-00169" summary=".">
       <created>1551170528833</created>
       <option name="project" value="LOCAL" />
       <updated>1566888335894</updated>
     </task>
-    <option name="localTasksCounter" value="217" />
+    <task id="LOCAL-00217" summary=".">
+      <created>1567019261000</created>
+      <option name="number" value="00217" />
+      <option name="presentableId" value="LOCAL-00217" />
+      <option name="project" value="LOCAL" />
+      <updated>1567019261001</updated>
+    </task>
+    <option name="localTasksCounter" value="218" />
     <servers />
   </component>
   <component name="TodoView">
index a73d5487a88b272d17605d10eca5252141075a6d..429dfd92fed5d755a30450beac3423897743f069 100644 (file)
@@ -39,7 +39,7 @@ function getSSHInstance($device = null, $sudo = false, $force = false)
 
 function sshCommand($command, $device = null, $blocking = true, $sudo = false)
 {
-    //return sshRunCommand($command, $device, $blocking, $sudo);
+    return sshRunCommand($command, $device, $blocking, $sudo);
     $redis = connectRedis();
     $queue = $redis->igbget('ssh_queue');
     if (!is_array($queue)) {
index ed01b5a4c55b57de4b35beb0aa17f2ab87427274..0bef892b8d04b42f4c170dacde37fef8cf3af047 100644 (file)
@@ -10,6 +10,7 @@ ignore_user_abort(true);
 echo 'Run home server insteon' . "\n";
 
 $redis = connectRedis();
+handleInsteonQueue();
 
 redisEventListener('insteon_event', 'handleInsteonQueue');
 
@@ -24,11 +25,14 @@ function handleInsteonQueue()
             $redis->igbset('insteon_queue', $queue);
         }
 
+
         if (!count($queue)) {
             echo 'Queue empty ' . "\n";
             break;
         }
 
+        $queue = array_unique($queue);
+
         echo 'Handle Queue : current state ' . json_encode($queue) . "\n";
 
         $command = array_shift($queue);
@@ -37,5 +41,5 @@ function handleInsteonQueue()
         runInsteonCommand($command);
         usleep(1000000 * 0.5);
     }
-    echo 'End of handling queue'."\n";
+    echo 'End of handling queue' . "\n";
 }
\ No newline at end of file
index b3142802a67f7a81a003d9658fa88ca397527862..9e8b56b1a934047488676131061e42a119b46c47 100644 (file)
@@ -3,6 +3,8 @@
 <?php
 require_once __DIR__ . "/../scripts/import.php";
 
+$processingSqueezeboxQueue = false;
+
 // Set time limit to indefinite execution
 set_time_limit(0);
 ignore_user_abort(true);
@@ -11,10 +13,19 @@ echo 'Run home server squeezebox' . "\n";
 
 $redis = connectRedis();
 redisEventListener('squeezebox_event', 'handleSqueezeboxQueue');
+handleSqueezeboxQueue();
 
 function handleSqueezeboxQueue()
 {
-    global $redis;
+    global $redis, $processingSqueezeboxQueue;
+
+    if ($processingSqueezeboxQueue) {
+        echo 'Already processing' . "\n";
+        return;
+    }
+
+    $processingSqueezeboxQueue = true;
+    echo 'Begin ' . $processingSqueezeboxQueue . "\n";
 
     while (true) {
         $q = 'squeezebox_queue';
@@ -24,7 +35,8 @@ function handleSqueezeboxQueue()
             $redis->igbset($q, $queue);
         }
         if (!count($queue)) {
-            echo 'End processing queue' . "\n";
+            echo 'End processing queue :)' . "\n";
+            $processingSqueezeboxQueue = false;
             break;
         }
 
@@ -32,5 +44,7 @@ function handleSqueezeboxQueue()
         $redis->igbset($q, $queue);
         echo 'Run command ' . json_encode($command) . "\n";
         _squeezeRequest($command[0], $command[1]);
+        usleep(0.05 * 1000000);
     }
+    $processingSqueezeboxQueue = false;
 }
\ No newline at end of file