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);
|
||||||
|
|||||||
@ -36,6 +36,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool _helpRequested;
|
bool _helpRequested;
|
||||||
|
std::string mConfigPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //Gradido_LoginServer_INCLUDED
|
#endif //Gradido_LoginServer_INCLUDED
|
||||||
|
|||||||
@ -51,6 +51,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Gradido_LoginServer app;
|
Gradido_LoginServer app;
|
||||||
|
app.setUnixOptions(true);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user