2 * @brief The updater class implementation. This class implements the updater logic.
6 * @copyright Intra2net AG
15 * Default constructor which initializes the member Conf.
20 LoggerPtr _log(new Logger);
24 ConfigPtr _config(new Config(Log));
27 Log->print_constructor_call("Updater");
36 Log->print_destructor_call("Updater");
41 * Parse the command line arguments and initialize corresponding options.
42 * @param argc Number command line arguments.
43 * @param argv[] Array with arguments.
44 * @return 0 if cmd options successfully parsed, 1 if usage or version.
46 int Updater::init_config_from_cmd(int argc, char *argv[])
48 // Load the command line parameters
49 if( Conf->parse_cmd_line( argc, argv ) != 0)
52 // If we have loaded the cmd options we need to init the log facility immediately in case debugging is enabled from cmd.
56 Log->print_cmd_parsed();
62 * Load the main config and the service definition files in config path.
63 * @return 0 if all is fine,
65 int Updater::init_config_from_files()
67 // Load the main and service config files in config path
68 if ( Conf->load_config_from_files() != 0 )
71 // Re-init log facility, perhaps new config file options for logger are set.
72 // These config file options will only overwrite the cmd options if the SIGHUP (reload config) is caught.
75 // Here we are. All Service Objects should be initialized, so it is time to deserialize the old service objects and compare them.
76 if ( Conf->deserialize_services() != 0 )
85 * Getter for member Config.
86 * @return Member Config.
88 ConfigPtr Updater::get_config()
95 * Getter for member Logger.
96 * @return Member Logger.
98 LoggerPtr Updater::get_logger()
105 * Reloading the config. Delete all Service objects and then init new Service objects from config files.
107 void Updater::reload_config()
109 // serialize all service objects
110 Conf->serialize_services();
112 // delete all service objects
113 Conf->delete_services();
115 // delete the actual Variables_map, perhaps with old cmd options which would overwrite new config file options.
116 Conf->delete_variables_map();
118 // load only config files
119 init_config_from_files();
124 * Initialize the logging facility with loglevel and syslog.
126 void Updater::init_log_facility()
128 Log->set_log_facility(Conf->get_loglevel(),Conf->get_syslog());
129 Log->print_init_log_facility();
134 * Update all configured services.
136 void Updater::update_services()
138 list<ServicePtr> services = this->Conf->get_services();
140 string ip = "192.168.1.1";
142 BOOST_FOREACH( ServicePtr service, services )