Fixed Twitter backend

This commit is contained in:
Jan Kaluza 2012-10-22 12:26:44 +02:00
parent 9a15e789ed
commit 3720df9cbe

View file

@ -27,58 +27,17 @@ int main (int argc, char* argv[]) {
return -1;
}
std::string configFile;
boost::program_options::variables_map vm;
boost::program_options::options_description desc("Usage: spectrum <config_file.cfg>\nAllowed options");
desc.add_options()
("help", "help")
("host,h", boost::program_options::value<std::string>(&host)->default_value(""), "Host to connect to")
("port,p", boost::program_options::value<int>(&port)->default_value(10000), "Port to connect to")
("config", boost::program_options::value<std::string>(&configFile)->default_value(""), "Config file")
;
try
{
boost::program_options::positional_options_description p;
p.add("config", -1);
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
options(desc).positional(p).allow_unregistered().run(), vm);
boost::program_options::notify(vm);
if(vm.count("help"))
{
std::cout << desc << "\n";
return 1;
}
if(vm.count("config") == 0) {
std::cout << desc << "\n";
return 1;
}
}
catch (std::runtime_error& e)
{
std::cout << desc << "\n";
return 1;
}
catch (...)
{
std::cout << desc << "\n";
return 1;
}
Config config(argc, argv);
if (!config.load(configFile)) {
std::cerr << "Can't open " << argv[1] << " configuration file.\n";
return 1;
}
Logging::initBackendLogging(&config);
std::string error;
Config *cfg = Config::createFromArgs(argc, argv, error, host, port);
if (cfg == NULL) {
std::cerr << error;
return 1;
}
Logging::initBackendLogging(cfg);
StorageBackend *storagebackend;
storagebackend = StorageBackend::createBackend(&config, error);
storagebackend = StorageBackend::createBackend(cfg, error);
if (storagebackend == NULL) {
LOG4CXX_ERROR(logger, "Error creating StorageBackend! " << error)
return -2;
@ -91,7 +50,7 @@ int main (int argc, char* argv[]) {
Swift::SimpleEventLoop eventLoop;
loop_ = &eventLoop;
np = new TwitterPlugin(&config, &eventLoop, storagebackend, host, port);
np = new TwitterPlugin(cfg, &eventLoop, storagebackend, host, port);
loop_->run();
return 0;