| 70 | } |
| 71 | |
| 72 | int main(int argc, char** argv) { |
| 73 | PredictorApi api; |
| 74 | |
| 75 | // initialize logger instance |
| 76 | #ifdef BCLOUD |
| 77 | logging::LoggingSettings settings; |
| 78 | settings.logging_dest = logging::LOG_TO_FILE; |
| 79 | |
| 80 | std::string filename(argv[0]); |
| 81 | filename = filename.substr(filename.find_last_of('/') + 1); |
| 82 | settings.log_file = (std::string("./log/") + filename + ".log").c_str(); |
| 83 | settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 84 | logging::InitLogging(settings); |
| 85 | |
| 86 | logging::ComlogSinkOptions cso; |
| 87 | cso.process_name = filename; |
| 88 | cso.enable_wf_device = true; |
| 89 | logging::ComlogSink::GetInstance()->Setup(&cso); |
| 90 | #else |
| 91 | struct stat st_buf; |
| 92 | int ret = 0; |
| 93 | if ((ret = stat("./log", &st_buf)) != 0) { |
| 94 | mkdir("./log", 0777); |
| 95 | ret = stat("./log", &st_buf); |
| 96 | if (ret != 0) { |
| 97 | LOG(WARNING) << "Log path ./log not exist, and create fail"; |
| 98 | return -1; |
| 99 | } |
| 100 | } |
| 101 | FLAGS_log_dir = "./log"; |
| 102 | google::InitGoogleLogging(strdup(argv[0])); |
| 103 | #endif |
| 104 | |
| 105 | if (api.create("./conf", "predictors.prototxt") != 0) { |
| 106 | LOG(ERROR) << "Failed create predictors api!"; |
| 107 | return -1; |
| 108 | } |
| 109 | |
| 110 | Request req; |
| 111 | Response res; |
| 112 | |
| 113 | api.thrd_initialize(); |
| 114 | |
| 115 | while (true) { |
| 116 | timeval start; |
| 117 | gettimeofday(&start, NULL); |
| 118 | |
| 119 | api.thrd_clear(); |
| 120 | |
| 121 | Predictor* predictor = api.fetch_predictor("sparse_service"); |
| 122 | if (!predictor) { |
| 123 | LOG(ERROR) << "Failed fetch predictor: sparse_service"; |
| 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | req.Clear(); |
| 128 | res.Clear(); |
| 129 |
nothing calls this directly
no test coverage detected