-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cc
64 lines (43 loc) · 1.43 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************
Author : Jun Zhang
Email : [email protected]
Last Modified : 2019-06-29 23:39
Filename : main.cc
Description :
*******************************************/
#include <iostream>
#include <chrono>
#include <gflags/gflags.h>
#include <brpc/server.h>
#include "service.h"
#include "options.h"
#include "engine_manager.h"
//#include "brpc/channel.h"
DEFINE_int32(port, 2019, "service port");
namespace sogou {
int run(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);
EngineManager& mgr = EngineManager::instance();
Options running_options;
mgr.Init(running_options);
brpc::Server server;
Service service;
if(server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
std::cout << "failed to add service." << std::endl;
return -1;
}
brpc::ServerOptions server_options;
if(server.Start(FLAGS_port, &server_options) != 0) {
std::cout << "failed to start service." << std::endl;
return -1;
}
server.RunUntilAskedToQuit();
auto begin = std::chrono::high_resolution_clock::now();
auto end = std::chrono::high_resolution_clock::now();
std::cout << "elapsed time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << std::endl;
return 0;
}
}
int main(int argc, char** argv) {
return sogou::run(argc, argv);
}