-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
54 lines (47 loc) · 1.28 KB
/
main.cpp
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
#include <memory>
#include <stdio.h>
#include <vector>
#include <csignal>
#include <algorithm>
#include "analyze/algorithm/ObjectDetector.h"
#include "AmApi.h"
#include "ServerProcCommunicator.h"
#include "ClientProcCommunicator.h"
#include "service/ConnectionsInfo.h"
#include "service/SilberService.h"
std::unique_ptr<am::service::SilberService> server;
void handleSignal(int signal)
{
std::cout << "Received SIGTERM signal (" << signal << "). Cleaning up and exiting...\n";
if (server)
{
server->stop();
server.reset();
}
exit(0);
}
int main(int argc, char *argv[])
{
#ifndef _WIN32
struct sigaction sa;
sa.sa_handler = handleSignal;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
// Set up handlers for SIGTERM and SIGINT
if (sigaction(SIGTERM, &sa, nullptr) == -1)
{
std::cerr << "Error setting up SIGTERM handler\n";
return 1;
}
if (sigaction(SIGINT, &sa, nullptr) == -1)
{
std::cerr << "Error setting up SIGINT handler\n";
return 1;
}
#endif
const std::string shared_memory_name{"/_shmem1107"};
server = std::make_unique<am::service::SilberService>(shared_memory_name);
server->start();
std::cout << "Aquamarine service performed all actions. Disconnect requested, exiting process..." << std::endl;
return 0;
}