Files
thehub/indexer/main.cpp
T

70 lines
2.4 KiB
C++
Raw Permalink Normal View History

2019-03-30 14:26:00 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2019 Tom Zander <tomz@freedommail.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QStandardPaths>
2019-05-07 20:53:22 +02:00
#include <FloweeServiceApplication.h>
2019-03-30 14:26:00 +01:00
#include "Indexer.h"
int main(int argc, char **argv)
{
2019-06-26 21:39:07 +02:00
setenv("QT_NO_GLIB", "1", 1);
2019-04-01 10:53:46 +02:00
FloweeServiceApplication app(argc, argv);
2019-03-30 14:26:00 +01:00
app.setOrganizationName("flowee");
app.setOrganizationDomain("flowee.org");
app.setApplicationName("indexer");
QCommandLineParser parser;
parser.setApplicationDescription("Indexing server");
parser.addHelpOption();
QCommandLineOption datadir(QStringList() << "datadir" << "d", "The directory to put the data in", "DIR");
parser.addOption(datadir);
2019-04-06 15:16:37 +02:00
QCommandLineOption conf(QStringList() << "conf", "config file", "FILENAME");
parser.addOption(conf);
app.addServerOptions(parser);
2019-04-01 10:53:46 +02:00
parser.process(app.arguments());
2019-05-09 12:15:34 +02:00
app.setup("indexer.log", parser.value(conf));
2019-03-30 14:26:00 +01:00
QString basedir;
if (parser.isSet(datadir))
basedir = parser.value(datadir);
else
basedir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
Indexer indexer(basedir.toStdString());
2019-04-09 19:34:55 +02:00
// become a server
2019-08-24 15:36:17 +02:00
for (auto ep : app.bindingEndPoints(parser, 1234, FloweeServiceApplication::LocalhostAsDefault)) {
logCritical().nospace() << "Trying to bind to " << ep.address().to_string().c_str() << ":" << ep.port();
try {
indexer.bind(ep);
} catch (std::exception &e) {
2019-08-24 15:36:17 +02:00
logCritical() << " nope, not binding there due to:" << e;
2019-04-09 19:34:55 +02:00
}
}
QString confFile;
if (parser.isSet(conf))
confFile = parser.value(conf);
else
confFile = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "indexer.conf");
indexer.loadConfig(confFile, app.serverAddressFromArguments(1235));
2019-03-30 14:26:00 +01:00
return app.exec();
}