RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
core/banker/banker_service.cc
00001 /* banker_service_runner.cc                                        -*- C++ -*-
00002    Jeremy Barnes, 20 November 2012
00003    Copyright (c) 2012 Datacratic.  All rights reserved.
00004 
00005    Runner for the banker service.
00006 */
00007 
00008 #include "master_banker.h"
00009 
00010 #include <boost/program_options/cmdline.hpp>
00011 #include <boost/program_options/options_description.hpp>
00012 #include <boost/program_options/positional_options.hpp>
00013 #include <boost/program_options/parsers.hpp>
00014 #include <boost/program_options/variables_map.hpp>
00015 #include "jml/arch/timers.h"
00016 
00017 
00018 using namespace std;
00019 using namespace ML;
00020 using namespace Datacratic;
00021 using namespace RTBKIT;
00022 
00023 
00024 int main(int argc, char ** argv)
00025 {
00026     using namespace boost::program_options;
00027 
00028     options_description service_options("Service options");
00029 
00030 #if 0
00031 
00032     service_options.add_options()
00033         ("num-threads,t", value<int>(&numThreads),
00034          "number of threads to start up");
00035 
00036     options_description logging_options("Logging options");
00037 
00038     logging_options.add_options()
00039         ("log-uri", value<vector<string> >(&logUris),
00040          "URI to publish logs to")
00041         ("carbon-connection,c", value<string>(&carbonConnection),
00042          "URI of connection to carbon daemon");
00043 #endif
00044 
00045     //positional_options_description p;
00046     //p.add("dataset", -1);
00047 
00048     options_description all_opt;
00049     all_opt
00050         .add(service_options);
00051     all_opt.add_options()
00052         ("help,h", "print this message");
00053     
00054     variables_map vm;
00055     store(command_line_parser(argc, argv)
00056           .options(all_opt)
00057           //.positional(p)
00058           .run(),
00059           vm);
00060     notify(vm);
00061 
00062     if (vm.count("help")) {
00063         cerr << all_opt << endl;
00064         return 1;
00065     }
00066 
00067     auto persistence = std::make_shared<RedisBankerPersistence>();
00068     auto proxies = std::make_shared<ServiceProxies>();
00069 
00070     string serviceName = "masterBanker";
00071 
00072     MasterBanker master(persistence, proxies, serviceName);
00073     auto addr = master.bindTcp();
00074     cerr << "master banker is listening on " << addr.first << ","
00075          << addr.second << endl;
00076 
00077     master.start();
00078 
00079     proxies->config->dump(cerr);
00080 
00081     for (;;) {
00082         ML::sleep(10);
00083     }
00084 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator