diff options
Diffstat (limited to '')
-rw-r--r-- | main.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -8,10 +8,11 @@ #include "config.h" #include "api/umosapi.h" +#include "service.hpp" + std::map<std::string, std::string> config; using namespace std; -using namespace Pistache; int main(int argc, char *argv[]) { @@ -26,16 +27,16 @@ int main(int argc, char *argv[]) { config_path.append("/.config/umosapi/config.txt"); bool showHelp = false; - int config_port = 9080; + config["port"] = "9080"; int thr = 2; auto cli = clara::detail::Help(showHelp) | clara::detail::Opt( config_path, "config" )["-c"]["--config"]("Config file path. Default `~/.config/umosapi/config.txt`.") - | clara::detail::Opt( config_port, "port" )["-p"]["--port"]("Port to listen. Default: `9080`.") + | clara::detail::Opt( config["port"], "port" )["-p"]["--port"]("Port to listen. Default: `9080`.") | clara::detail::Opt( thr, "treads" )["-t"]["--threads"]("Number of threads. Default: `2`."); auto result = cli.parse( clara::detail::Args( argc, argv ) ); if( !result ) { - std::cerr << "Error in command line: " << result.errorMessage() << std::endl; + std::cerr << "ERROR: Error in command line: " << result.errorMessage() << std::endl; std::cerr << cli << std::endl; exit(1); } @@ -45,27 +46,35 @@ int main(int argc, char *argv[]) { exit(1); } - Address addr(Ipv4::any(), Port(config_port)); + //Address addr(Ipv4::any(), Port(config["port"])); - cout << "Using " << hardware_concurrency() << " cores"; + cout << "INFO: Using " << std::thread::hardware_concurrency() << " cores"; cout << " - " << thr << " threads" << endl; - cout << "Listen on 0.0.0.0:" << config_port << endl; + cout << "INFO: Listen on 0.0.0.0:" << config["port"] << endl; - cout << "Using config file '" << config_path << "'" << endl; + cout << "INFO: Using config file '" << config_path << "'" << endl; if (!std::filesystem::exists(config_path)) { - cout << "Error fatal : config file '" << config_path << "' not found" << endl; - cout << "config.txt is search here: ~/.config/umosapi/config.txt" << endl; + cout << "ERROR: Error fatal : config file '" << config_path << "' not found" << endl; + cout << "ERROR: config.txt is search here: ~/.config/umosapi/config.txt" << endl; exit (EXIT_FAILURE); } load_config(config_path); - cout << "Using swaggerui " << config["swaggerui"] << " path" << endl; - cout << "Using mongoURI " << config["mongoURI"] << endl; + //cout << "Using swaggerui " << config["swaggerui"] << " path" << endl; + cout << "INFO: No support for swagger for the moment" << endl; + cout << "INFO: Using mongoURI " << config["mongoURI"] << endl; + /* UmosapiService umosapi(addr); umosapi.init(thr); umosapi.start(config["swaggerui"]); + */ + + UmosapiService umosapi; + umosapi.init(); + umosapi.start(std::stoi(config["port"]), thr); + } |