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

Function main

tools/cpp_examples/demo-client/src/dense_format.cpp:62–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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