-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUbiDeviceServerMain.cpp
More file actions
42 lines (33 loc) · 998 Bytes
/
UbiDeviceServerMain.cpp
File metadata and controls
42 lines (33 loc) · 998 Bytes
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
/*
* Copyright 2020 by Siklu Ltd. All rights reserved.
*/
#include <folly/init/Init.h>
#include <folly/logging/xlog.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>
#include <csignal>
#include "ServerSignalHandler.h"
#include "UbiDeviceFactory.h"
#include "UbiDeviceServer.h"
static constexpr int kThriftPort = 12999;
int main(int argc, char* argv[]) {
FLAGS_logtostderr = 1;
google::InstallFailureSignalHandler();
folly::init(&argc, &argv);
auto ubi_device_factory = std::make_shared<UbiDeviceFactory>();
auto maybe_server =
UbiDeviceServer::CreateServer(kThriftPort, ubi_device_factory);
if (!maybe_server) {
XLOG(CRITICAL) << "failed to create server";
return -1;
}
ServerSignalHandler signal_handler(*maybe_server);
try {
signal_handler.registerSignalHandler(SIGTERM);
} catch (...) {
XLOG(CRITICAL) << "failed to register signal SIGTERM";
return -1;
}
XLOG(INFO) << "server: starts";
maybe_server->get()->serve();
return 0;
}