<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">
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)) {
echo 'Run home server insteon' . "\n";
$redis = connectRedis();
+handleInsteonQueue();
redisEventListener('insteon_event', '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);
runInsteonCommand($command);
usleep(1000000 * 0.5);
}
- echo 'End of handling queue'."\n";
+ echo 'End of handling queue' . "\n";
}
\ No newline at end of file
<?php
require_once __DIR__ . "/../scripts/import.php";
+$processingSqueezeboxQueue = false;
+
// Set time limit to indefinite execution
set_time_limit(0);
ignore_user_abort(true);
$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';
$redis->igbset($q, $queue);
}
if (!count($queue)) {
- echo 'End processing queue' . "\n";
+ echo 'End processing queue :)' . "\n";
+ $processingSqueezeboxQueue = false;
break;
}
$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