Compare commits
2 Commits
646dc18718
...
d4fce11f5a
Author | SHA1 | Date |
---|---|---|
Dirk Heilig | d4fce11f5a | |
Dirk Heilig | 5f188442a1 |
|
@ -14,5 +14,4 @@ ADD . /app
|
||||||
|
|
||||||
VOLUME /app/public
|
VOLUME /app/public
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT /app/generator.php
|
ENTRYPOINT /app/generator.php
|
||||||
|
|
|
@ -16,4 +16,3 @@ variables:
|
||||||
werkstatt_temp:
|
werkstatt_temp:
|
||||||
topic: c3re/werkstatttemp
|
topic: c3re/werkstatttemp
|
||||||
cast: float
|
cast: float
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ $c->onMessage(function (\Mosquitto\Message $message) use (&$data, $conf) {
|
||||||
" unknown\n";
|
" unknown\n";
|
||||||
die(1);
|
die(1);
|
||||||
}
|
}
|
||||||
var_dump($data);
|
|
||||||
$data[$message->topic]["changed"] = time();
|
$data[$message->topic]["changed"] = time();
|
||||||
$out = file_get_contents(__DIR__ . "/template.json");
|
$out = file_get_contents(__DIR__ . "/template.json");
|
||||||
$out = preg_replace_callback(
|
$out = preg_replace_callback(
|
||||||
|
@ -69,7 +68,9 @@ $c->onMessage(function (\Mosquitto\Message $message) use (&$data, $conf) {
|
||||||
if (!is_dir("public")) {
|
if (!is_dir("public")) {
|
||||||
mkdir("public");
|
mkdir("public");
|
||||||
}
|
}
|
||||||
file_put_contents("public/spaceapi.json", $out);
|
file_put_contents("public/spaceapi.json.new", $out);
|
||||||
|
// ensure atomic update
|
||||||
|
rename("public/spaceapi.json.new", "public/spaceapi.json");
|
||||||
});
|
});
|
||||||
$c->connect($conf["mqtt"]["host"]);
|
$c->connect($conf["mqtt"]["host"]);
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
Loading…
Reference in New Issue