70 lines
1.5 KiB
C++
Executable File
70 lines
1.5 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* main for Buildings
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
|
|
#include "main_handler.h"
|
|
#include "logger.h"
|
|
#include "settings.h"
|
|
|
|
#ifdef Q_OS_LINUX
|
|
#include <sys/resource.h>
|
|
#endif
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
|
|
LtsCommandLineParser::LtsCommandLineParser options;
|
|
if (!options.init())
|
|
return -1;
|
|
app.createLogger("BLD", options.exerciseId());
|
|
|
|
#ifdef Q_OS_LINUX
|
|
constexpr int fdLimit = 8192;
|
|
struct rlimit rl;
|
|
if (getrlimit (RLIMIT_NOFILE, &rl) == 0)
|
|
{
|
|
if (rl.rlim_cur < fdLimit || rl.rlim_max < fdLimit)
|
|
{
|
|
struct rlimit rlNew = rl;
|
|
rlNew.rlim_cur = fdLimit;
|
|
if (rlNew.rlim_max < rlNew.rlim_cur)
|
|
rlNew.rlim_cur = rlNew.rlim_max;
|
|
|
|
if (rlNew.rlim_cur != rl.rlim_cur)
|
|
{
|
|
if (setrlimit (RLIMIT_NOFILE, &rlNew) == 0)
|
|
DEBUG_LOG(app.baseLogger()) << "setting RLIMIT_NOFILE to " << rlNew.rlim_cur;
|
|
else
|
|
WARNING_LOG(app.baseLogger()) << "failed setting RLIMIT_NOFILE to " << fdLimit;
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
Buildings::Settings::setIniFile(options.iniFile());
|
|
|
|
int iRet = -3;
|
|
{
|
|
std::unique_ptr<Buildings::MainHandler> mainHandler(new Buildings::MainHandler);
|
|
|
|
if (!mainHandler->init(options.domainId(), options.exerciseId()))
|
|
return iRet;
|
|
|
|
STARTUP_LOG(app.baseLogger());
|
|
|
|
iRet = app.exec();
|
|
|
|
SHUTDOWN_LOG(app.baseLogger());
|
|
}
|
|
|
|
return iRet;
|
|
}
|