-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (71 loc) · 2.37 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "alisesettings.h"
#include "commandlineparser.h"
#include "controllerfabric.h"
#include "gitversion/gitversion.h"
#include "logger.h"
#include "maincreator.h"
#include <QCoreApplication>
#include <config.h>
#include <iostream>
#include <memory>
constexpr char ethPathString[] = "/etc/network/interfaces.d/eth";
constexpr char ethResourcePathString[] = ":/network/eth";
int main(int argc, char *argv[])
{
MainCreator creator;
bool ok;
Broker *broker;
TimeSyncronizer *tm;
ControllerFabric fabric;
AliseSettings settings;
CommandLineParser parser;
std::cout << "Started " << std::endl;
qRegisterMetaType<uint32_t>("uint32_t");
GitVersion gitVersion;
QCoreApplication a(argc, argv);
a.setApplicationVersion(QString(ALISEVERSION) + "-" + gitVersion.getGitHash());
StdFunc::Init();
settings.init();
settings.readSettings();
if (!parser.parseCommandLine(settings))
return 0;
Logger::writeStart(settings.logFilename);
Logger::setLogLevel(settings.logLevel);
qInstallMessageHandler(Logger::messageHandler);
settings.logSettings();
for (const QString ethLetter : { "0", "1", "2" })
{
QString ethPath = ethPathString + ethLetter;
QString ethResourcePath = ethResourcePathString + ethLetter;
if (!QFile::exists(ethResourcePath))
qInfo() << "Recovery eth" << ethLetter << ": not found";
else
qInfo() << "Recovery eth" << ethLetter << ": found";
}
qInfo() << "=========================\n";
creator.init();
broker = creator.create(ok);
if (!ok)
{
qCritical() << "Can't create broker, exiting";
return 11;
}
tm = creator.getTimeSynchronizer();
if (!fabric.createController(Controller::ContrTypes::IS_BOOTER, settings.portBooter, broker, tm))
{
qCritical() << "Booter controller was not created, exiting";
return 12;
}
if (!fabric.createController(Controller::ContrTypes::IS_CORE, settings.portCore, broker, tm))
{
qCritical() << "Core controller was not created, exiting";
return 13;
}
if (!fabric.createController(Controller::ContrTypes::IS_ADMINJA, settings.portAdminja, broker, tm))
{
qCritical() << "Core controller was not created, exiting";
return 14;
}
std::cout << "Enter the event loop" << std::endl;
return a.exec();
}