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);
|
||||
|
||||
options.addOption(
|
||||
/*options.addOption(
|
||||
Poco::Util::Option("help", "h", "display help information on command line arguments")
|
||||
.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)
|
||||
{
|
||||
//printf("handle option: %s with value: %s\n", name.data(), value.data());
|
||||
if (name == "config") {
|
||||
mConfigPath = value;
|
||||
return;
|
||||
}
|
||||
ServerApplication::handleOption(name, value);
|
||||
if (name == "help") _helpRequested = true;
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Profiler usedTime;
|
||||
if (_helpRequested)
|
||||
{
|
||||
@ -134,12 +147,16 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
|
||||
// *************** 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 {
|
||||
loadConfiguration(cfg_Path + "grd_login.properties");
|
||||
loadConfiguration(cfg_Path);
|
||||
}
|
||||
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);
|
||||
|
||||
@ -1,41 +1,42 @@
|
||||
#ifndef Gradido_LoginServer_INCLUDED
|
||||
#define Gradido_LoginServer_INCLUDED
|
||||
|
||||
#include "Poco/Util/ServerApplication.h"
|
||||
|
||||
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
||||
{
|
||||
|
||||
/// The main application class.
|
||||
///
|
||||
/// This class handles command-line arguments and
|
||||
/// configuration files.
|
||||
/// Start the Gradido_LoginServer executable with the help
|
||||
/// option (/help on Windows, --help on Unix) for
|
||||
/// the available command line options.
|
||||
///
|
||||
|
||||
|
||||
public:
|
||||
Gradido_LoginServer();
|
||||
~Gradido_LoginServer();
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
|
||||
void uninitialize();
|
||||
|
||||
void defineOptions(Poco::Util::OptionSet& options);
|
||||
|
||||
void handleOption(const std::string& name, const std::string& value);
|
||||
void displayHelp();
|
||||
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
};
|
||||
|
||||
#endif //Gradido_LoginServer_INCLUDED
|
||||
#ifndef Gradido_LoginServer_INCLUDED
|
||||
#define Gradido_LoginServer_INCLUDED
|
||||
|
||||
#include "Poco/Util/ServerApplication.h"
|
||||
|
||||
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
||||
{
|
||||
|
||||
/// The main application class.
|
||||
///
|
||||
/// This class handles command-line arguments and
|
||||
/// configuration files.
|
||||
/// Start the Gradido_LoginServer executable with the help
|
||||
/// option (/help on Windows, --help on Unix) for
|
||||
/// the available command line options.
|
||||
///
|
||||
|
||||
|
||||
public:
|
||||
Gradido_LoginServer();
|
||||
~Gradido_LoginServer();
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
|
||||
void uninitialize();
|
||||
|
||||
void defineOptions(Poco::Util::OptionSet& options);
|
||||
|
||||
void handleOption(const std::string& name, const std::string& value);
|
||||
void displayHelp();
|
||||
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
std::string mConfigPath;
|
||||
};
|
||||
|
||||
#endif //Gradido_LoginServer_INCLUDED
|
||||
|
||||
111
src/cpp/main.cpp
111
src/cpp/main.cpp
@ -1,56 +1,57 @@
|
||||
#include "Gradido_LoginServer.h"
|
||||
#include <sodium.h>
|
||||
|
||||
#include "proto/gradido/TransactionBody.pb.h"
|
||||
|
||||
#include "model/User.h"
|
||||
#include "model/Session.h"
|
||||
#include "lib/Profiler.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ImportantTests.h"
|
||||
|
||||
#include "model/table/User.h"
|
||||
#include "model/table/EmailOptIn.h"
|
||||
|
||||
#include "Poco/DateTimeParser.h"
|
||||
|
||||
#ifndef _TEST_BUILD
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
if (sodium_init() < 0) {
|
||||
/* panic! the library couldn't be initialized, it is not safe to use */
|
||||
printf("error initializing sodium, early exit\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string dateTimeString = __DATE__;
|
||||
//printf("Building date time string: %s\n", dateTimeString.data());
|
||||
std::string formatString("%b %d %Y");
|
||||
int timeZone = 0;
|
||||
|
||||
Poco::DateTime buildDateTime = Poco::DateTimeParser::parse(formatString, dateTimeString, timeZone);
|
||||
ServerConfig::g_versionString = Poco::DateTimeFormatter::format(buildDateTime, "0.%y.%m.%d");
|
||||
//ServerConfig::g_versionString = "0.20.KW13.02";
|
||||
printf("Version: %s\n", ServerConfig::g_versionString.data());
|
||||
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));
|
||||
|
||||
// load word lists
|
||||
if (!ServerConfig::loadMnemonicWordLists()) {
|
||||
//printf("[Gradido_LoginServer::%s] error loading mnemonic Word List\n", __FUNCTION__);
|
||||
printf("[Gradido_LoginServer::main] error loading mnemonic Word List");
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (!ImportantTests::passphraseGenerationAndTransformation()) {
|
||||
printf("test passphrase generation and transformation failed\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
Gradido_LoginServer app;
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
#include "Gradido_LoginServer.h"
|
||||
#include <sodium.h>
|
||||
|
||||
#include "proto/gradido/TransactionBody.pb.h"
|
||||
|
||||
#include "model/User.h"
|
||||
#include "model/Session.h"
|
||||
#include "lib/Profiler.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ImportantTests.h"
|
||||
|
||||
#include "model/table/User.h"
|
||||
#include "model/table/EmailOptIn.h"
|
||||
|
||||
#include "Poco/DateTimeParser.h"
|
||||
|
||||
#ifndef _TEST_BUILD
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
if (sodium_init() < 0) {
|
||||
/* panic! the library couldn't be initialized, it is not safe to use */
|
||||
printf("error initializing sodium, early exit\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string dateTimeString = __DATE__;
|
||||
//printf("Building date time string: %s\n", dateTimeString.data());
|
||||
std::string formatString("%b %d %Y");
|
||||
int timeZone = 0;
|
||||
|
||||
Poco::DateTime buildDateTime = Poco::DateTimeParser::parse(formatString, dateTimeString, timeZone);
|
||||
ServerConfig::g_versionString = Poco::DateTimeFormatter::format(buildDateTime, "0.%y.%m.%d");
|
||||
//ServerConfig::g_versionString = "0.20.KW13.02";
|
||||
printf("Version: %s\n", ServerConfig::g_versionString.data());
|
||||
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));
|
||||
|
||||
// load word lists
|
||||
if (!ServerConfig::loadMnemonicWordLists()) {
|
||||
//printf("[Gradido_LoginServer::%s] error loading mnemonic Word List\n", __FUNCTION__);
|
||||
printf("[Gradido_LoginServer::main] error loading mnemonic Word List");
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (!ImportantTests::passphraseGenerationAndTransformation()) {
|
||||
printf("test passphrase generation and transformation failed\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
Gradido_LoginServer app;
|
||||
app.setUnixOptions(true);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user