summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/configuration.cc4
-rw-r--r--server/src/configurationparser.cc57
-rw-r--r--server/src/pracrod.cc20
3 files changed, 66 insertions, 15 deletions
diff --git a/server/src/configuration.cc b/server/src/configuration.cc
index 20d1c75..fc2da6a 100644
--- a/server/src/configuration.cc
+++ b/server/src/configuration.cc
@@ -36,5 +36,5 @@ port_t Conf::journal_commit_port = 18112;
time_t Conf::db_max_ttl = 60 * 60 * 24;
time_t Conf::pentominos_max_ttl = 60 * 60 * 24;
-std::string pentominos_addr = "localhost";
-port_t pentominos_potr = 11108;
+std::string Conf::pentominos_addr = "localhost";
+port_t Conf::pentominos_port = 11108;
diff --git a/server/src/configurationparser.cc b/server/src/configurationparser.cc
index 6335fd9..3065907 100644
--- a/server/src/configurationparser.cc
+++ b/server/src/configurationparser.cc
@@ -26,6 +26,8 @@
*/
#include "configurationparser.h"
+#include "configuration.h"
+
ConfigurationParser::ConfigurationParser(std::string filename)
{
this->filename = filename;
@@ -46,4 +48,59 @@ void ConfigurationParser::reload()
throw ConfigurationParserException(std::string("Error when parsing the config file in line ")
+ lineno + ": " + e.getError());
}
+
+ // Set internal values
+ try {
+ int p = lookup("server_port");
+ Conf::server_port = p;
+ } catch( ... ) {
+ }
+
+ try {
+ std::string u = lookup("server_user");
+ Conf::server_user = u;
+ } catch( ... ) {
+ }
+
+ try {
+ std::string g = lookup("server_group");
+ Conf::server_group = g;
+ } catch( ... ) {
+ }
+
+ try {
+ std::string a = lookup("journal_commit_addr");
+ Conf::journal_commit_addr = a;
+ } catch( ... ) {
+ }
+
+ try {
+ int p = lookup("journal_commit_port");
+ Conf::journal_commit_port = p;
+ } catch( ... ) {
+ }
+
+ try {
+ int t = lookup("db_max_ttl");
+ Conf::db_max_ttl = t;
+ } catch( ... ) {
+ }
+
+ try {
+ int t = lookup("pentominos_max_ttl");
+ Conf::pentominos_max_ttl = t;
+ } catch( ... ) {
+ }
+
+ try {
+ std::string a = lookup("pentominos_addr");
+ Conf::pentominos_addr = a;
+ } catch( ... ) {
+ }
+
+ try {
+ int p = lookup("pentominos_port");
+ Conf::pentominos_port = p;
+ } catch( ... ) {
+ }
}
diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc
index c668159..6ee1817 100644
--- a/server/src/pracrod.cc
+++ b/server/src/pracrod.cc
@@ -52,6 +52,7 @@
// For getopt_long and friends
#include <getopt.h>
+#include "configurationparser.h"
#include "configuration.h"
#include "server.h"
@@ -82,19 +83,19 @@ static const char usage_str[] =
" -h, --help Print this message and exit.\n"
;
+ConfigurationParser *configparser = NULL;
+
void reload(int)
{
- /*
int port;
printf("Reload!\n");
- port = config()->lookup("port");
- config()->reload();
+ port = configparser->lookup("port");
+ configparser->reload();
{ // Force wake the server process for reinitialization.
TCPSocket socket;
socket.connect("localhost", port);
}
- */
}
class PracroDaemon : public Daemon {
@@ -170,15 +171,8 @@ int main(int argc, char *argv[])
}
// Load config
- /*
- char defval[512];
- sprintf(defval, ETC"/pracrod.conf");
- char *cfname = NULL;
- if(!configfile) cfname = defval;//ETC"/pracrod.conf";
- else cfname = configfile;
- Configuration conf(cfname);
- initConfig(&conf);
- */
+ if(configfile) configparser = new ConfigurationParser(configfile);
+ else configparser = new ConfigurationParser(ETC"/pracrod.conf");
if(!user) {
user = strdup(Conf::server_user.c_str());