Add timestamp checking on automatic restart script

This commit is contained in:
30hours 2023-10-28 07:40:36 +10:30
parent ce0cb20a42
commit d209df39da
2 changed files with 5 additions and 1 deletions

View file

@ -4,8 +4,11 @@
# Checks the API to see if data is still being pushed through. # Checks the API to see if data is still being pushed through.
FIRST_CHAR=$(curl -s 127.0.0.1:3000/map | head -c1) 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 docker compose -f /opt/blah2/docker-compose.yml down
systemctl restart sdrplay.service systemctl restart sdrplay.service
docker compose -f /opt/blah2/docker-compose.yml up -d docker compose -f /opt/blah2/docker-compose.yml up -d

View file

@ -134,6 +134,7 @@ std::string Map<T>::to_json()
// get posix time // get posix time
uint64_t timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); uint64_t timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
document.AddMember("timestamp", timestamp/1000, allocator);
document.AddMember("nRows", nRows, allocator); document.AddMember("nRows", nRows, allocator);
document.AddMember("nCols", nCols, allocator); document.AddMember("nCols", nCols, allocator);
document.AddMember("noisePower", noisePower, allocator); document.AddMember("noisePower", noisePower, allocator);