MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / main

Function main

tools/cpp_examples/demo-client/src/load_general_model.cpp:46–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

statClass · 0.70
create_reqFunction · 0.70
print_resFunction · 0.70
createMethod · 0.45
thrd_initializeMethod · 0.45
thrd_clearMethod · 0.45
fetch_predictorMethod · 0.45
ClearMethod · 0.45
debugMethod · 0.45
ShortDebugStringMethod · 0.45
tagMethod · 0.45
thrd_finalizeMethod · 0.45

Tested by

no test coverage detected