Added restart as recovery when connection to devices is lost.

Added a heardbeat-file into which a timestamp is written every second.
This commit is contained in:
hg
2014-06-30 22:07:03 +02:00
parent 40d5753edc
commit c2c25dd30e
5 changed files with 238 additions and 9 deletions
+12 -1
View File
@@ -32,6 +32,7 @@ std::string socketPath = "/opt/growcontrol/growcontrold.socket";
std::string log4cppConfig = "log4cpp.config";
std::string host = "localhost";
std::string workDir = "/opt/growcontrol";
std::string heartBeatFile = "/opt/growcontrol/growcontrold.heartbeat";
uint16_t port = 4223;
bool daemonMode = false;
int pid_fd = 0;
@@ -68,6 +69,7 @@ void printUsage(std::ostream& stream, std::string name) {
<< "\t-l ... path to log4cpp config file" << std::endl
<< "\t-h ... brickd address" << std::endl
<< "\t-p ... brickd port" << std::endl
<< "\t-hb ... heartbeat file" << std::endl
<< "\t-w ... working directory" << std::endl;
}
@@ -126,6 +128,15 @@ int main(int argc, char **argv) {
printUsage(std::cerr, argv[0]);
exit(1);
}
} else if (strcmp(argv[t], "-hb") == 0) {
if (t+1 < argc && argv[t+1][0] != '-') {
t++;
heartBeatFile = argv[t];
} else {
std::cerr << "Option -hb is missing an argument." << std::endl << std::endl;
printUsage(std::cerr, argv[0]);
exit(1);
}
} else if (strcmp(argv[t], "-p") == 0) {
if (t+1 < argc && argv[t+1][0] != '-') {
t++;
@@ -176,7 +187,7 @@ int main(int argc, char **argv) {
} catch (GCException &e) {
}
controller.mainLoop();
controller.mainLoop(heartBeatFile);
logger << log4cpp::Priority::WARN << "Shutting down ipc ...";