| 43 | } |
| 44 | |
| 45 | int main(int argc, char** argv) { |
| 46 | PredictorApi api; |
| 47 | |
| 48 | // initialize logger instance |
| 49 | #ifdef BCLOUD |
| 50 | logging::LoggingSettings settings; |
| 51 | settings.logging_dest = logging::LOG_TO_FILE; |
| 52 | |
| 53 | std::string filename(argv[0]); |
| 54 | filename = filename.substr(filename.find_last_of('/') + 1); |
| 55 | settings.log_file = (std::string("./log/") + filename + ".log").c_str(); |
| 56 | settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 57 | logging::InitLogging(settings); |
| 58 | |
| 59 | logging::ComlogSinkOptions cso; |
| 60 | cso.process_name = filename; |
| 61 | cso.enable_wf_device = true; |
| 62 | logging::ComlogSink::GetInstance()->Setup(&cso); |
| 63 | #else |
| 64 | struct stat st_buf; |
| 65 | int ret = 0; |
| 66 | if ((ret = stat("./log", &st_buf)) != 0) { |
| 67 | mkdir("./log", 0777); |
| 68 | ret = stat("./log", &st_buf); |
| 69 | if (ret != 0) { |
| 70 | LOG(WARNING) << "Log path ./log not exist, and create fail"; |
| 71 | return -1; |
| 72 | } |
| 73 | } |
| 74 | FLAGS_log_dir = "./log"; |
| 75 | google::InitGoogleLogging(strdup(argv[0])); |
| 76 | #endif |
| 77 | |
| 78 | if (api.create("./conf", "predictors.prototxt") != 0) { |
| 79 | LOG(ERROR) << "Failed create predictors api!"; |
| 80 | return -1; |
| 81 | } |
| 82 | |
| 83 | RequestAndResponse req; |
| 84 | RequestAndResponse res; |
| 85 | |
| 86 | api.thrd_initialize(); |
| 87 | |
| 88 | while (true) { |
| 89 | timeval start; |
| 90 | gettimeofday(&start, NULL); |
| 91 | |
| 92 | api.thrd_clear(); |
| 93 | |
| 94 | Predictor* predictor = api.fetch_predictor("echo_service"); |
| 95 | if (!predictor) { |
| 96 | LOG(ERROR) << "Failed fetch predictor: echo_service"; |
| 97 | return -1; |
| 98 | } |
| 99 | |
| 100 | req.Clear(); |
| 101 | res.Clear(); |
| 102 |
nothing calls this directly
no test coverage detected