Files

73 lines
2.7 KiB
C++
Raw Permalink Normal View History

2019-03-30 14:26:00 +01:00
/*
* This file is part of the Flowee project
2025-02-20 20:32:13 +01:00
* Copyright (C) 2019-2025 Tom Zander <tom@flowee.org>
2019-03-30 14:26:00 +01:00
*
* 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);
QCommandLineOption conf(QStringList() << "conf", "Logging config file", "FILENAME");
2019-04-06 15:16:37 +02:00
parser.addOption(conf);
app.addServerOptions(parser);
2019-04-01 10:53:46 +02:00
parser.process(app.arguments());
app.setup("indexer.log");
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
2025-02-20 20:32:13 +01:00
int bindCount = app.bindWith(1234, FloweeServiceApplication::AllInterfacesAsDefault,
[&indexer](const boost::asio::ip::tcp::endpoint &ep) {
logCritical().nospace() << "Binding to " << ep.address().to_string().c_str() << ", port:" << ep.port();
indexer.bind(ep);
});
if (bindCount == 0) {
logFatal() << "Service did not manage to listen, already running?";
return 1;
2019-04-09 19:34:55 +02:00
}
QString confFile;
if (parser.isSet(conf))
confFile = parser.value(conf);
2021-02-06 23:07:07 +01:00
else // the next one expects [configs]/flowee/indexer/indexer.conf
confFile = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "indexer.conf");
2021-02-06 23:07:07 +01:00
if (confFile.isEmpty()) // the next one expects [configs]/flowee/indexer.conf
confFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, "flowee/indexer.conf");
indexer.loadConfig(confFile, app.serverAddressFromArguments(1235));
2019-03-30 14:26:00 +01:00
return app.exec();
}