Added instance ID
This commit is contained in:
parent
8c3fb6b88d
commit
04e0dfeab0
4 changed files with 11 additions and 0 deletions
|
@ -286,6 +286,14 @@ int main_loop(int argc, char ** argv){
|
||||||
|
|
||||||
Controller::Log("CONF", "Controller started");
|
Controller::Log("CONF", "Controller started");
|
||||||
Controller::conf.activate();//activate early, so threads aren't killed.
|
Controller::conf.activate();//activate early, so threads aren't killed.
|
||||||
|
//Generate instanceId once per boot.
|
||||||
|
if (Controller::instanceId == ""){
|
||||||
|
srand(time(NULL));
|
||||||
|
do{
|
||||||
|
Controller::instanceId += (char)(64 + rand() % 62);
|
||||||
|
}while(Controller::instanceId.size() < 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//start stats thread
|
//start stats thread
|
||||||
tthread::thread statsThread(Controller::SharedMemStats, &Controller::conf);
|
tthread::thread statsThread(Controller::SharedMemStats, &Controller::conf);
|
||||||
|
|
|
@ -351,6 +351,7 @@ void Controller::handleAPICommands(JSON::Value & Request, JSON::Value & Response
|
||||||
//sent current configuration, if not minimal or was changed/requested
|
//sent current configuration, if not minimal or was changed/requested
|
||||||
if (!Request.isMember("minimal") || Request.isMember("config")){
|
if (!Request.isMember("minimal") || Request.isMember("config")){
|
||||||
Response["config"] = Controller::Storage["config"];
|
Response["config"] = Controller::Storage["config"];
|
||||||
|
Response["config"]["iid"] = instanceId;
|
||||||
Response["config"]["version"] = PACKAGE_VERSION;
|
Response["config"]["version"] = PACKAGE_VERSION;
|
||||||
//add required data to the current unix time to the config, for syncing reasons
|
//add required data to the current unix time to the config, for syncing reasons
|
||||||
Response["config"]["time"] = Util::epoch();
|
Response["config"]["time"] = Util::epoch();
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
///\brief Holds everything unique to the controller.
|
///\brief Holds everything unique to the controller.
|
||||||
namespace Controller {
|
namespace Controller {
|
||||||
|
std::string instanceId; /// instanceId (previously uniqId) is set in controller.cpp
|
||||||
|
|
||||||
Util::Config conf;
|
Util::Config conf;
|
||||||
JSON::Value Storage; ///< Global storage of data.
|
JSON::Value Storage; ///< Global storage of data.
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <mist/tinythread.h>
|
#include <mist/tinythread.h>
|
||||||
|
|
||||||
namespace Controller {
|
namespace Controller {
|
||||||
|
extern std::string instanceId; ///<global storage of instanceId (previously uniqID) is set in controller.cpp
|
||||||
extern Util::Config conf;///< Global storage of configuration.
|
extern Util::Config conf;///< Global storage of configuration.
|
||||||
extern JSON::Value Storage; ///< Global storage of data.
|
extern JSON::Value Storage; ///< Global storage of data.
|
||||||
extern tthread::mutex logMutex;///< Mutex for log thread.
|
extern tthread::mutex logMutex;///< Mutex for log thread.
|
||||||
|
|
Loading…
Add table
Reference in a new issue