5 using GTS::SettingsParser;
7 SettingsParser::SettingsParser()
8 : _desc("Allowed options")
10 // Declare the supported options.
12 ("help", "produce help message")
13 ("config,c", po::value<std::string>()->default_value("/etc/gssmd/gssmd.conf"), "config file location")
14 ("daemon,d", "daemonize after start")
15 ("debug", "gssmd debugging")
16 ("log-file", po::value<std::string>(), "log file location")
17 ("pid-file", po::value<std::string>(), "PID file location")
18 ("switch-sync-interval,s", po::value<time_t>(), "switch synchronization interval")
19 ("info-sync-interval,i", po::value<time_t>(), "info synchronization interval")
20 ("up-profile-id", po::value<unsigned>(), "switch's upload profile id")
21 ("down-profile-id", po::value<unsigned>(), "switch's download profile id")
22 ("data-url", po::value<std::string>(), "data access URL")
23 ("version,v", "show gssmd version and exit")
27 void SettingsParser::init(int argc, char * argv[])
30 po::store(po::parse_command_line(argc, argv, _desc), vm);
33 _settings._isHelp = vm.count("help");
34 _settings._isVersion = vm.count("version");
36 if (vm.count("config")) {
37 _settings._configFile = vm["config"].as<std::string>();
40 if (!_settings._isHelp &&
41 !_settings._isVersion) {
43 parseFile(_settings._configFile);
45 catch (std::exception & ex) {
46 logger << "Error parsing config file '" << _settings._configFile << "': " << ex.what() << std::endl;
50 if (vm.count("debug")) {
51 _settings._isDebug = true;
53 if (vm.count("daemon")) {
54 _settings._isDaemon = true;
57 if (vm.count("log-file")) {
58 _settings._logFile = vm["log-file"].as<std::string>();
61 if (vm.count("pid-file")) {
62 _settings._PIDFile = vm["pid-file"].as<std::string>();
65 if (vm.count("switch-sync-interval")) {
66 _settings._switchSyncInterval = vm["switch-sync-interval"].as<time_t>();
69 if (vm.count("info-sync-interval")) {
70 _settings._infoSyncInterval = vm["info-sync-interval"].as<time_t>();
73 if (vm.count("up-profile-id")) {
74 _settings._upProfileId = vm["up-profile-id"].as<unsigned>();
77 if (vm.count("down-profile-id")) {
78 _settings._downProfileId = vm["down-profile-id"].as<unsigned>();
81 if (vm.count("data-url")) {
82 _settings._dataURL = vm["data-url"].as<std::string>();
86 void SettingsParser::reloadConfig()
88 parseFile(_settings._configFile);