7ecf23e391
Separate the log-conf and service-config file locations. Avoid providing a bind on the commandline, make it come from the config file instead.
81 lines
2.7 KiB
C++
81 lines
2.7 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2019-2025 Tom Zander <tom@flowee.org>
|
|
*
|
|
* 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 "StorageWebServer.h"
|
|
#include <QStandardPaths>
|
|
|
|
#include <FloweeServiceApplication.h>
|
|
#include <primitives/PrivateKey.h> // for ECC_Start()
|
|
|
|
namespace {
|
|
struct ECC_State
|
|
{
|
|
ECC_State() {
|
|
// Init crypto lib.
|
|
ECC_Start();
|
|
globalVerifyHandle.reset(new ECCVerifyHandle());
|
|
}
|
|
~ECC_State() {
|
|
globalVerifyHandle.reset();
|
|
ECC_Stop();
|
|
}
|
|
|
|
std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
|
|
};
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
FloweeServiceApplication app(argc, argv);
|
|
app.setOrganizationName("flowee");
|
|
app.setOrganizationDomain("flowee.org");
|
|
app.setApplicationName("storage-backup-server");
|
|
|
|
QCommandLineParser parser;
|
|
parser.setApplicationDescription("Wallet Storage Server");
|
|
parser.addHelpOption();
|
|
QCommandLineOption conf(QStringList() << "conf", "config file", "FILENAME");
|
|
parser.addOption(conf);
|
|
app.addServerOptions(parser);
|
|
parser.process(app.arguments());
|
|
app.setup("walletStorage.log");
|
|
|
|
QString confFile;
|
|
if (parser.isSet(conf)) {
|
|
confFile = parser.value(conf);
|
|
} else {
|
|
// the next one expects [configs]/flowee/bitcore-proxy/bitcore-proxy.conf
|
|
confFile = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "walletStorage.conf");
|
|
if (confFile.isEmpty()) // the next one expects [configs]/flowee/bitcore-proxy.conf
|
|
confFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, "flowee/walletStorage.conf");
|
|
if (confFile.isEmpty()) {
|
|
logCritical() << "No config file (walletStorage.conf) found, assuming defaults";
|
|
for (auto &dir : QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation)) {
|
|
logInfo() << " - not found in" << dir + '/';
|
|
}
|
|
}
|
|
}
|
|
StorageWebServer server;
|
|
server.loadConfig(confFile);
|
|
ECC_State crypo_state; // allows the secp256k1 to function.
|
|
|
|
QObject::connect (&app, SIGNAL(reparseConfig()), &server, SLOT(reparseConfig()));
|
|
|
|
return app.exec();
|
|
}
|