Support for reloading config from disk, writing config to disk after 60 seconds of no changes, reloading config from disk on API call request

This commit is contained in:
Thulinma 2023-06-03 03:16:32 +02:00
parent cac86fff57
commit 132e59db51
8 changed files with 339 additions and 222 deletions

View file

@ -3,21 +3,6 @@
#include "shared_memory.h"
#include "util.h"
#define COMM_STATUS_SOURCE 0x80
#define COMM_STATUS_DONOTTRACK 0x40
#define COMM_STATUS_DISCONNECT 0x20
#define COMM_STATUS_REQDISCONNECT 0x10
#define COMM_STATUS_ACTIVE 0x1
#define COMM_STATUS_INVALID 0x0
#define SESS_BUNDLE_DEFAULT_VIEWER 14
#define SESS_BUNDLE_DEFAULT_OTHER 15
#define SESS_DEFAULT_STREAM_INFO_MODE 1
#define SESS_HTTP_AS_VIEWER 1
#define SESS_HTTP_AS_OUTPUT 2
#define SESS_HTTP_DISABLED 3
#define SESS_HTTP_AS_UNSPECIFIED 4
#define SESS_TKN_DEFAULT_MODE 15
#define COMM_LOOP(comm, onActive, onDisconnect) \
{\

View file

@ -285,3 +285,20 @@ static inline void show_stackframe(){}
#define NEW_TRACK_ID 0x80000000
#define QUICK_NEGOTIATE 0xC0000000
// Session and Comm library related constants
#define COMM_STATUS_SOURCE 0x80
#define COMM_STATUS_DONOTTRACK 0x40
#define COMM_STATUS_DISCONNECT 0x20
#define COMM_STATUS_REQDISCONNECT 0x10
#define COMM_STATUS_ACTIVE 0x1
#define COMM_STATUS_INVALID 0x0
#define SESS_BUNDLE_DEFAULT_VIEWER 14
#define SESS_BUNDLE_DEFAULT_OTHER 15
#define SESS_DEFAULT_STREAM_INFO_MODE 1
#define SESS_HTTP_AS_VIEWER 1
#define SESS_HTTP_AS_OUTPUT 2
#define SESS_HTTP_DISABLED 3
#define SESS_HTTP_AS_UNSPECIFIED 4
#define SESS_TKN_DEFAULT_MODE 15

View file

@ -5,6 +5,7 @@
#include <cstdio>
#include <cstring>
#include <sys/time.h> //for gettimeofday
#include <sys/stat.h>
#include <time.h> //for time and nanosleep
#include <sstream>
#include <stdlib.h>
@ -166,3 +167,13 @@ std::string Util::getDateString(uint64_t epoch){
strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S %z", timeinfo);
return std::string(buffer);
}
/// Gets unix time of last file modification, or 0 if this information is not available for any reason
uint64_t Util::getFileUnixTime(const std::string & filename){
struct stat fInfo;
if (stat(filename.c_str(), &fInfo) == 0){
return fInfo.st_mtime;
}
return 0;
}

View file

@ -21,4 +21,5 @@ namespace Util{
uint64_t getMSFromUTCString(std::string UTCString);
uint64_t getUTCTimeDiff(std::string UTCString, uint64_t epochMillis);
std::string getDateString(uint64_t epoch = 0);
uint64_t getFileUnixTime(const std::string & filename);
}// namespace Util