-
Notifications
You must be signed in to change notification settings - Fork 273
/
syncd_main.cpp
74 lines (49 loc) · 1.79 KB
/
syncd_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "sairediscommon.h"
#include "CommandLineOptionsParser.h"
#include "Syncd.h"
#include "MetadataLogger.h"
#include "PortMapParser.h"
#include "swss/warm_restart.h"
#ifdef SAITHRIFT
#include <utility>
#include <algorithm>
#include <switch_sai_rpc_server.h>
#endif // SAITHRIFT
#ifdef SAITHRIFT
#define SWITCH_SAI_THRIFT_RPC_SERVER_PORT 9092
#endif // SAITHRIFT
using namespace syncd;
/*
* Make sure that notification queue pointer is populated before we start
* thread, and before we create_switch, since at switch_create we can start
* receiving fdb_notifications which will arrive on different thread and
* will call getQueueSize() when queue pointer could be null (this=0x0).
*/
int syncd_main(int argc, char **argv)
{
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG);
SWSS_LOG_ENTER();
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE);
swss::Logger::linkToDbNative("syncd");
swss::WarmStart::initialize("syncd", "syncd");
swss::WarmStart::checkWarmStart("syncd", "syncd");
bool isWarmStart = swss::WarmStart::isWarmStart();
MetadataLogger::initialize();
auto commandLineOptions = CommandLineOptionsParser::parseCommandLine(argc, argv);
#ifdef SAITHRIFT
if (commandLineOptions->m_portMapFile.size() > 0)
{
auto map = PortMapParser::parsePortMap(commandLineOptions->m_portMapFile);
PortMap::setGlobalPortMap(map);
}
if (commandLineOptions->m_runRPCServer)
{
start_sai_thrift_rpc_server(SWITCH_SAI_THRIFT_RPC_SERVER_PORT);
SWSS_LOG_NOTICE("rpcserver started");
}
#endif // SAITHRIFT
auto vendorSai = std::make_shared<VendorSai>();
auto syncd = std::make_shared<Syncd>(vendorSai, commandLineOptions, isWarmStart);
syncd->run();
return EXIT_SUCCESS;
}