Line data Source code
1 : #include <signal.h>
2 : #include <thrift/protocol/TBinaryProtocol.h>
3 : #include <thrift/server/TThreadedServer.h>
4 : #include <thrift/transport/TBufferTransports.h>
5 : #include <thrift/transport/TServerSocket.h>
6 :
7 : #include "../utils.h"
8 : #include "../utils_thrift.h"
9 : #include "MediaHandler.h"
10 :
11 : extern "C" void __gcov_flush();
12 :
13 : using apache::thrift::protocol::TBinaryProtocolFactory;
14 : using apache::thrift::server::TThreadedServer;
15 : using apache::thrift::transport::TFramedTransportFactory;
16 : using apache::thrift::transport::TServerSocket;
17 : using namespace social_network;
18 :
19 0 : void sigintHandler(int sig) { exit(EXIT_SUCCESS); }
20 :
21 1 : void handle_sigusr1(int signum) {
22 1 : __gcov_flush();
23 0 : }
24 :
25 1 : int main(int argc, char *argv[]) {
26 1 : signal(SIGINT, sigintHandler);
27 1 : signal(SIGUSR1, handle_sigusr1);
28 1 : init_logger();
29 1 : SetUpTracer("config/jaeger-config.yml", "media-service");
30 1 : json config_json;
31 1 : if (load_config_file("config/service-config.json", &config_json) != 0) {
32 0 : exit(EXIT_FAILURE);
33 : }
34 :
35 1 : int port = config_json["media-service"]["port"];
36 1 : std::shared_ptr<TServerSocket> server_socket = get_server_socket(config_json, "0.0.0.0", port);
37 :
38 : TThreadedServer server(
39 2 : std::make_shared<MediaServiceProcessor>(std::make_shared<MediaHandler>()),
40 : server_socket,
41 2 : std::make_shared<TFramedTransportFactory>(),
42 6 : std::make_shared<TBinaryProtocolFactory>());
43 :
44 2 : LOG(info) << "Starting the media-service server...";
45 1 : server.serve();
46 3 : }
|