Initial commit
[remote/remote-mci.git] / diku_mcs / Configuration.cc
blobce05a556a9cb25b4a69beb22f3b61c2ee7746041
1 #include "Configuration.h"
3 namespace remote { namespace diku_mcs {
5 void Configuration::read(int ac, char** av )
7 // command line options
8 po::options_description cmdline_options("commandlineoptions");
9 cmdline_options.add_options()
10 ("config-file",
11 po::value<std::string>()->default_value("/etc/diku_mcs.cfg"),
12 "Path to the configuration file.")
13 ("daemonize",
14 po::value<int>()->default_value(false),
15 "Run as a daemon.");
17 // declare all configuration groups
18 po::options_description config("Configuration");
20 config.add_options()
21 ("dbName",
22 po::value<std::string>(),
23 "Name of the infrastructure database.")
24 ("dbHost",
25 po::value<std::string>(),
26 "Host name of the infrastructure database server.")
27 ("dbUser",
28 po::value<std::string>(),
29 "User name for the infrastructure database.")
30 ("dbPassword",
31 po::value<std::string>(),
32 "Password for the infrastructure database.")
33 ("sessionListenerPort",
34 po::value<unsigned int>()->default_value(10000),
35 "Port number to use when listening for new sessions.")
36 ("hostListenerPort",
37 po::value<unsigned int>()->default_value(10001),
38 "Port number to use when listening for new hosts.")
39 ("log-file",
40 po::value<std::string>()->default_value("/var/log/diku_mcs.log"),
41 "Path to the output log file when running as a daemon.")
42 ("errorlog-file",
43 po::value<std::string>()->default_value("/var/log/diku_mcs_error.log"),
44 "Path to the error log file when running as a daemon.")
47 store(po::parse_command_line(ac, av, cmdline_options), vm);
48 notify(vm);
50 // get the configuration settings from a file
51 std::ifstream ifs(Configuration::vm["config-file"].as<std::string>().c_str());
52 store(parse_config_file(ifs, config), vm);
53 notify(vm);
56 po::variables_map Configuration::vm;