mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add option for custom properties (for example to run more than one login-server on a server) using like:
This commit is contained in:
parent
fc363a1ef1
commit
adffede699
@ -54,16 +54,28 @@ void Gradido_LoginServer::defineOptions(Poco::Util::OptionSet& options)
|
|||||||
{
|
{
|
||||||
ServerApplication::defineOptions(options);
|
ServerApplication::defineOptions(options);
|
||||||
|
|
||||||
options.addOption(
|
/*options.addOption(
|
||||||
Poco::Util::Option("help", "h", "display help information on command line arguments")
|
Poco::Util::Option("help", "h", "display help information on command line arguments")
|
||||||
.required(false)
|
.required(false)
|
||||||
.repeatable(false));
|
.repeatable(false));*/
|
||||||
|
options.addOption(
|
||||||
|
Poco::Util::Option("config", "c", "use non default config file (default is /etc/grd_login.properties)", false)
|
||||||
|
.repeatable(false)
|
||||||
|
.argument("Gradido_LoginServer.properties", true)
|
||||||
|
.callback(Poco::Util::OptionCallback<Gradido_LoginServer>(this, &Gradido_LoginServer::handleOption)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gradido_LoginServer::handleOption(const std::string& name, const std::string& value)
|
void Gradido_LoginServer::handleOption(const std::string& name, const std::string& value)
|
||||||
{
|
{
|
||||||
|
//printf("handle option: %s with value: %s\n", name.data(), value.data());
|
||||||
|
if (name == "config") {
|
||||||
|
mConfigPath = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
ServerApplication::handleOption(name, value);
|
ServerApplication::handleOption(name, value);
|
||||||
if (name == "help") _helpRequested = true;
|
if (name == "help") _helpRequested = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gradido_LoginServer::displayHelp()
|
void Gradido_LoginServer::displayHelp()
|
||||||
@ -93,6 +105,7 @@ void Gradido_LoginServer::createConsoleFileAsyncLogger(std::string name, std::st
|
|||||||
|
|
||||||
int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
|
|
||||||
Profiler usedTime;
|
Profiler usedTime;
|
||||||
if (_helpRequested)
|
if (_helpRequested)
|
||||||
{
|
{
|
||||||
@ -134,12 +147,16 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
// *************** load from config ********************************************
|
// *************** load from config ********************************************
|
||||||
|
|
||||||
std::string cfg_Path = Poco::Path::config() + "grd_login/";
|
std::string cfg_Path = Poco::Path::config() + "grd_login/grd_login.properties";
|
||||||
|
if (mConfigPath != "") {
|
||||||
|
cfg_Path = mConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadConfiguration(cfg_Path + "grd_login.properties");
|
loadConfiguration(cfg_Path);
|
||||||
}
|
}
|
||||||
catch (Poco::Exception& ex) {
|
catch (Poco::Exception& ex) {
|
||||||
errorLog.error("error loading config: %s", ex.displayText());
|
errorLog.error("error loading config: %s from path: %s", ex.displayText(), cfg_Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short port = (unsigned short)config().getInt("HTTPServer.port", 9980);
|
unsigned short port = (unsigned short)config().getInt("HTTPServer.port", 9980);
|
||||||
|
|||||||
@ -1,41 +1,42 @@
|
|||||||
#ifndef Gradido_LoginServer_INCLUDED
|
#ifndef Gradido_LoginServer_INCLUDED
|
||||||
#define Gradido_LoginServer_INCLUDED
|
#define Gradido_LoginServer_INCLUDED
|
||||||
|
|
||||||
#include "Poco/Util/ServerApplication.h"
|
#include "Poco/Util/ServerApplication.h"
|
||||||
|
|
||||||
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
||||||
{
|
{
|
||||||
|
|
||||||
/// The main application class.
|
/// The main application class.
|
||||||
///
|
///
|
||||||
/// This class handles command-line arguments and
|
/// This class handles command-line arguments and
|
||||||
/// configuration files.
|
/// configuration files.
|
||||||
/// Start the Gradido_LoginServer executable with the help
|
/// Start the Gradido_LoginServer executable with the help
|
||||||
/// option (/help on Windows, --help on Unix) for
|
/// option (/help on Windows, --help on Unix) for
|
||||||
/// the available command line options.
|
/// the available command line options.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Gradido_LoginServer();
|
Gradido_LoginServer();
|
||||||
~Gradido_LoginServer();
|
~Gradido_LoginServer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initialize(Application& self);
|
void initialize(Application& self);
|
||||||
|
|
||||||
void uninitialize();
|
void uninitialize();
|
||||||
|
|
||||||
void defineOptions(Poco::Util::OptionSet& options);
|
void defineOptions(Poco::Util::OptionSet& options);
|
||||||
|
|
||||||
void handleOption(const std::string& name, const std::string& value);
|
void handleOption(const std::string& name, const std::string& value);
|
||||||
void displayHelp();
|
void displayHelp();
|
||||||
|
|
||||||
int main(const std::vector<std::string>& args);
|
int main(const std::vector<std::string>& args);
|
||||||
|
|
||||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _helpRequested;
|
bool _helpRequested;
|
||||||
};
|
std::string mConfigPath;
|
||||||
|
};
|
||||||
#endif //Gradido_LoginServer_INCLUDED
|
|
||||||
|
#endif //Gradido_LoginServer_INCLUDED
|
||||||
|
|||||||
111
src/cpp/main.cpp
111
src/cpp/main.cpp
@ -1,56 +1,57 @@
|
|||||||
#include "Gradido_LoginServer.h"
|
#include "Gradido_LoginServer.h"
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
#include "proto/gradido/TransactionBody.pb.h"
|
#include "proto/gradido/TransactionBody.pb.h"
|
||||||
|
|
||||||
#include "model/User.h"
|
#include "model/User.h"
|
||||||
#include "model/Session.h"
|
#include "model/Session.h"
|
||||||
#include "lib/Profiler.h"
|
#include "lib/Profiler.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "ImportantTests.h"
|
#include "ImportantTests.h"
|
||||||
|
|
||||||
#include "model/table/User.h"
|
#include "model/table/User.h"
|
||||||
#include "model/table/EmailOptIn.h"
|
#include "model/table/EmailOptIn.h"
|
||||||
|
|
||||||
#include "Poco/DateTimeParser.h"
|
#include "Poco/DateTimeParser.h"
|
||||||
|
|
||||||
#ifndef _TEST_BUILD
|
#ifndef _TEST_BUILD
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
if (sodium_init() < 0) {
|
if (sodium_init() < 0) {
|
||||||
/* panic! the library couldn't be initialized, it is not safe to use */
|
/* panic! the library couldn't be initialized, it is not safe to use */
|
||||||
printf("error initializing sodium, early exit\n");
|
printf("error initializing sodium, early exit\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dateTimeString = __DATE__;
|
std::string dateTimeString = __DATE__;
|
||||||
//printf("Building date time string: %s\n", dateTimeString.data());
|
//printf("Building date time string: %s\n", dateTimeString.data());
|
||||||
std::string formatString("%b %d %Y");
|
std::string formatString("%b %d %Y");
|
||||||
int timeZone = 0;
|
int timeZone = 0;
|
||||||
|
|
||||||
Poco::DateTime buildDateTime = Poco::DateTimeParser::parse(formatString, dateTimeString, timeZone);
|
Poco::DateTime buildDateTime = Poco::DateTimeParser::parse(formatString, dateTimeString, timeZone);
|
||||||
ServerConfig::g_versionString = Poco::DateTimeFormatter::format(buildDateTime, "0.%y.%m.%d");
|
ServerConfig::g_versionString = Poco::DateTimeFormatter::format(buildDateTime, "0.%y.%m.%d");
|
||||||
//ServerConfig::g_versionString = "0.20.KW13.02";
|
//ServerConfig::g_versionString = "0.20.KW13.02";
|
||||||
printf("Version: %s\n", ServerConfig::g_versionString.data());
|
printf("Version: %s\n", ServerConfig::g_versionString.data());
|
||||||
printf("User size: %d Bytes, Session size: %d Bytes\n", sizeof(User), sizeof(Session));
|
printf("User size: %d Bytes, Session size: %d Bytes\n", sizeof(User), sizeof(Session));
|
||||||
printf("model sizes: User: %d Bytes, EmailOptIn: %d Bytes\n", sizeof(model::table::User), sizeof(model::table::EmailOptIn));
|
printf("model sizes: User: %d Bytes, EmailOptIn: %d Bytes\n", sizeof(model::table::User), sizeof(model::table::EmailOptIn));
|
||||||
|
|
||||||
// load word lists
|
// load word lists
|
||||||
if (!ServerConfig::loadMnemonicWordLists()) {
|
if (!ServerConfig::loadMnemonicWordLists()) {
|
||||||
//printf("[Gradido_LoginServer::%s] error loading mnemonic Word List\n", __FUNCTION__);
|
//printf("[Gradido_LoginServer::%s] error loading mnemonic Word List\n", __FUNCTION__);
|
||||||
printf("[Gradido_LoginServer::main] error loading mnemonic Word List");
|
printf("[Gradido_LoginServer::main] error loading mnemonic Word List");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ImportantTests::passphraseGenerationAndTransformation()) {
|
if (!ImportantTests::passphraseGenerationAndTransformation()) {
|
||||||
printf("test passphrase generation and transformation failed\n");
|
printf("test passphrase generation and transformation failed\n");
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gradido_LoginServer app;
|
Gradido_LoginServer app;
|
||||||
return app.run(argc, argv);
|
app.setUnixOptions(true);
|
||||||
}
|
return app.run(argc, argv);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user