Bug-fixes & persistent saving of important parameters

This commit is contained in:
hg
2014-06-19 00:40:58 +02:00
parent 6c5ea5a39f
commit 4c24d7a834
11 changed files with 314 additions and 20 deletions
+14 -3
View File
@@ -31,6 +31,7 @@ std::string pidFile = "/var/run/growcontrold.pid";
std::string socketPath = "/opt/growcontrol/growcontrold.socket";
std::string log4cppConfig = "log4cpp.config";
std::string host = "localhost";
std::string workDir = "/opt/growcontrol";
uint16_t port = 4223;
bool daemonMode = false;
int pid_fd = 0;
@@ -60,13 +61,14 @@ void signalHandler(int signum) {
void printUsage(std::ostream& stream, std::string name) {
stream << "Usage: " << name << " [-d] [-pid pid-file] [-s socket-path] [-l log4cpp-config] [-h host] [-p port]" << std::endl
stream << "Usage: " << name << " [-d] [-pid pid-file] [-s socket-path] [-l log4cpp-config] [-h host] [-p port] [-w work-dir]" << std::endl
<< "\t-d ... daemon mode" << std::endl
<< "\t-pid ... pid-file" << std::endl
<< "\t-s ... path of ipc socket" << std::endl
<< "\t-l ... path to log4cpp config file" << std::endl
<< "\t-h ... brickd address" << std::endl
<< "\t-p ... brickd port" << std::endl;
<< "\t-p ... brickd port" << std::endl
<< "\t-w ... working directory" << std::endl;
}
@@ -106,6 +108,15 @@ int main(int argc, char **argv) {
printUsage(std::cerr, argv[0]);
exit(1);
}
} else if (strcmp(argv[t], "-w") == 0) {
if (t+1 < argc && argv[t+1][0] != '-') {
t++;
workDir = argv[t];
} else {
std::cerr << "Option -w is missing an argument." << std::endl << std::endl;
printUsage(std::cerr, argv[0]);
exit(1);
}
} else if (strcmp(argv[t], "-h") == 0) {
if (t+1 < argc && argv[t+1][0] != '-') {
t++;
@@ -156,7 +167,7 @@ int main(int argc, char **argv) {
signal(SIGINT, signalHandler);
signal(SIGHUP, signalHandler);
controller.connect(host, port);
controller.connect(workDir, host, port);
if (!termSignalCaught) {
sleep(2);