51 lines
1.2 KiB
C++
Raw Normal View History

2019-01-02 14:19:39 +03:00
#include <QCoreApplication>
#include <serverutils.h>
#include <quasarapp.h>
2019-03-10 16:56:42 +03:00
#include <serverutils.h>
#include <mainserver.h>
2019-01-02 14:19:39 +03:00
int main(int argc, char *argv[])
{
if (!ServerUtils::parseParams(argc, argv)) {
2019-03-10 22:07:05 +03:00
ServerUtils::helpDaemon();
2019-01-02 14:19:39 +03:00
return 1;
}
if (QuasarAppUtils::Params::isEndable("help") ||
QuasarAppUtils::Params::isEndable("h")) {
2019-03-10 22:07:05 +03:00
ServerUtils::helpDaemon();
2019-01-02 14:19:39 +03:00
return 0;
}
2019-05-13 10:13:22 +03:00
QString address = "";
unsigned short port = 0;
2019-05-18 19:05:36 +03:00
QString db = "";
2019-05-13 10:13:22 +03:00
if(QuasarAppUtils::Params::isEndable("address")) {
address = QuasarAppUtils::Params::getStrArg("address");
}
if(QuasarAppUtils::Params::isEndable("port")) {
2019-05-18 19:05:36 +03:00
port = static_cast<unsigned short>(QuasarAppUtils::Params::getArg("port").toUInt());
}
if(QuasarAppUtils::Params::isEndable("db")) {
db = QuasarAppUtils::Params::getStrArg("db");
2019-01-02 14:19:39 +03:00
}
2019-05-18 19:05:36 +03:00
2019-05-13 10:26:40 +03:00
if(ServerUtils::runDaemon()) {
return 0;
}
2019-01-02 14:19:39 +03:00
QCoreApplication a(argc, argv);
2019-05-13 10:13:22 +03:00
MainServer mainServer;
if (!mainServer.run(address, port)) {
2019-03-10 21:20:51 +03:00
QuasarAppUtils::Params::verboseLog("server is not run!");
2019-03-10 22:07:05 +03:00
ServerUtils::helpDaemon();
2019-03-10 21:20:51 +03:00
return 1;
}
2019-01-02 14:19:39 +03:00
return a.exec();
}