From d209df39daaf8dd3b2ca1beb4c620232f5505d30 Mon Sep 17 00:00:00 2001 From: 30hours Date: Sat, 28 Oct 2023 07:40:36 +1030 Subject: [PATCH] Add timestamp checking on automatic restart script --- script/blah2.bash | 5 ++++- src/data/Map.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/script/blah2.bash b/script/blah2.bash index 8616cc5..67f4475 100755 --- a/script/blah2.bash +++ b/script/blah2.bash @@ -4,8 +4,11 @@ # Checks the API to see if data is still being pushed through. FIRST_CHAR=$(curl -s 127.0.0.1:3000/map | head -c1) +TIMESTAMP=$(curl -s 127.0.0.1:3000/map | head -c23 | tail -c10) +CURR_TIMESTAMP=$(date +%s) +DIFF_TIMESTAMP=$(($CURR_TIMESTAMP-$TIMESTAMP)) -if [[ "$FIRST_CHAR" != "{" ]]; then +if [[ "$FIRST_CHAR" != "{" ]] || [[ $DIFF_TIMESTAMP -gt 60 ]]; then docker compose -f /opt/blah2/docker-compose.yml down systemctl restart sdrplay.service docker compose -f /opt/blah2/docker-compose.yml up -d diff --git a/src/data/Map.cpp b/src/data/Map.cpp index 2398859..ba5bdc6 100644 --- a/src/data/Map.cpp +++ b/src/data/Map.cpp @@ -134,6 +134,7 @@ std::string Map::to_json() // get posix time uint64_t timestamp = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + document.AddMember("timestamp", timestamp/1000, allocator); document.AddMember("nRows", nRows, allocator); document.AddMember("nCols", nCols, allocator); document.AddMember("noisePower", noisePower, allocator);