From f849ac25e4663450ef2d0b6e5efcb551f1f3861f Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Thu, 29 Aug 2024 10:54:08 +0200 Subject: [PATCH] make json atomar --- mqtt2prom/run | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mqtt2prom/run b/mqtt2prom/run index da69d4e..68c0475 100755 --- a/mqtt2prom/run +++ b/mqtt2prom/run @@ -276,12 +276,13 @@ function output(): void } file_put_contents("/www/metrics/new.prom", $prom); file_put_contents( - "/www/metrics/json", + "/www/metrics/new.json", json_encode( $json, JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE ) ); + rename("/www/metrics/new.json", "/www/metrics/metrics.json"); rename("/www/metrics/new.prom", "/www/metrics/index.prom"); // return $prom; }