Compare commits

..

No commits in common. "d4fce11f5a949dd08b99184cf2fbebe9ad17ac3c" and "646dc187184f30ea3398957065e03e5198f02736" have entirely different histories.

3 changed files with 13 additions and 12 deletions

View File

@ -14,4 +14,5 @@ ADD . /app
VOLUME /app/public
ENTRYPOINT /app/generator.php

View File

@ -16,3 +16,4 @@ variables:
werkstatt_temp:
topic: c3re/werkstatttemp
cast: float

View File

@ -35,6 +35,7 @@ $c->onMessage(function (\Mosquitto\Message $message) use (&$data, $conf) {
" unknown\n";
die(1);
}
var_dump($data);
$data[$message->topic]["changed"] = time();
$out = file_get_contents(__DIR__ . "/template.json");
$out = preg_replace_callback(
@ -68,9 +69,7 @@ $c->onMessage(function (\Mosquitto\Message $message) use (&$data, $conf) {
if (!is_dir("public")) {
mkdir("public");
}
file_put_contents("public/spaceapi.json.new", $out);
// ensure atomic update
rename("public/spaceapi.json.new", "public/spaceapi.json");
file_put_contents("public/spaceapi.json", $out);
});
$c->connect($conf["mqtt"]["host"]);
$data = [];