virtual int Start() = 0;
virtual int Stop() = 0;
- virtual int Reload() = 0;
+ virtual int Reload(const MODULE_SETTINGS &) = 0;
virtual bool IsRunning() = 0;
virtual const std::string & GetStrError() const = 0;
virtual std::string GetVersion() const = 0;
switch (sig)
{
case SIGHUP:
+ {
+ SETTINGS_IMPL newSettings(settings);
+ if (newSettings.ReadSettings())
+ {
+ STG_LOGGER & WriteServLog = GetStgLogger();
+
+ if (newSettings.GetLogFileName() != "")
+ WriteServLog.SetLogFileName(newSettings.GetLogFileName());
+
+ WriteServLog("ReadSettings error. %s", newSettings.GetStrError().c_str());
+ return -1;
+ }
+ settings = newSettings;
traffCnt.Reload();
- manager.reload();
+ manager.reload(settings);
+ }
break;
case SIGTERM:
running = false;
for (size_t i = 0; i < modSettings.size(); i++)
{
std::string modulePath = basePath + "/mod_" + modSettings[i].moduleName + ".so";
+ std::string moduleName = modSettings[i].moduleName;
printfd(__FILE__, "Module: %s\n", modulePath.c_str());
try
{
m_modules.push_back(
- new PLUGIN_RUNNER(modulePath, modSettings[i], admins, tariffs,
+ new PLUGIN_RUNNER(modulePath, moduleName, modSettings[i], admins, tariffs,
users, services, corporations, traffcounter,
store, settings)
);
delete m_modules[i];
}
-void PluginManager::reload()
+void PluginManager::reload(const SETTINGS_IMPL& settings)
{
+ const std::vector<MODULE_SETTINGS> & modSettings(settings.GetModulesSettings());
for (size_t i = 0; i < m_modules.size(); ++i)
{
- PLUGIN & plugin = m_modules[i]->GetPlugin();
- if (m_modules[i]->Reload())
+ for (size_t j = 0; j < modSettings.size(); j++)
{
- m_log("Error reloading module '%s': '%s'", plugin.GetVersion().c_str(),
- plugin.GetStrError().c_str());
- printfd(__FILE__, "Error reloading module '%s': '%s'\n", plugin.GetVersion().c_str(),
- plugin.GetStrError().c_str());
+ if (modSettings[j].moduleName == m_modules[i]->GetName())
+ {
+ PLUGIN & plugin = m_modules[i]->GetPlugin();
+ if (m_modules[i]->Reload(modSettings[j]))
+ {
+ m_log("Error reloading module '%s': '%s'", plugin.GetVersion().c_str(),
+ plugin.GetStrError().c_str());
+ printfd(__FILE__, "Error reloading module '%s': '%s'\n", plugin.GetVersion().c_str(),
+ plugin.GetStrError().c_str());
+ }
+ }
}
}
}
USERS_IMPL& users, TRAFFCOUNTER_IMPL& traffcounter);
~PluginManager();
- void reload();
+ void reload(const SETTINGS_IMPL& settings);
void stop();
private:
//-----------------------------------------------------------------------------
PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & fileName,
+ const std::string & name,
const MODULE_SETTINGS & ms,
ADMINS & admins,
TARIFFS & tariffs,
STORE & store,
const SETTINGS & settings)
: pluginFileName(fileName),
+ pluginName(name),
libHandle(NULL),
m_plugin(Load(ms, admins, tariffs, users, services, corporations,
traffcounter, store, settings))
return res;
}
//-----------------------------------------------------------------------------
-int PLUGIN_RUNNER::Reload()
+int PLUGIN_RUNNER::Reload(const MODULE_SETTINGS & ms)
{
-int res = m_plugin.Reload();
+int res = m_plugin.Reload(ms);
errorStr = m_plugin.GetStrError();
return res;
}
};
PLUGIN_RUNNER(const std::string & pluginFileName,
+ const std::string & pluginName,
const MODULE_SETTINGS & ms,
ADMINS & admins,
TARIFFS & tariffs,
int Start();
int Stop();
- int Reload();
+ int Reload(const MODULE_SETTINGS & ms);
int Restart();
bool IsRunning() { return m_plugin.IsRunning(); }
const std::string & GetStrError() const { return errorStr; }
PLUGIN & GetPlugin() { return m_plugin; }
const std::string & GetFileName() const { return pluginFileName; }
+ const std::string & GetName() const { return pluginName; }
uint16_t GetStartPosition() const { return m_plugin.GetStartPosition(); }
uint16_t GetStopPosition() const { return m_plugin.GetStopPosition(); }
const SETTINGS & settings);
std::string pluginFileName;
+ std::string pluginName;
void * libHandle;
PLUGIN & m_plugin;
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
void SetSettings(const MODULE_SETTINGS &) {}
int ParseSettings() { return 0; }
return ret;
}
//-----------------------------------------------------------------------------
+int AUTH_IA::Reload(const MODULE_SETTINGS & ms)
+{
+AUTH_IA_SETTINGS newIaSettings;
+if (newIaSettings.ParseSettings(ms))
+ {
+ STG_LOGGER & WriteServLog = GetStgLogger();
+ printfd(__FILE__, "AUTH_IA::Reload() - Failed to reload InetAccess.\n");
+ WriteServLog("AUTH_IA: Cannot reload InetAccess. Errors found.");
+ return -1;
+ }
+
+STG_LOGGER & WriteServLog = GetStgLogger();
+printfd(__FILE__, "AUTH_IA::Reload() - Reloaded InetAccess successfully.\n");
+WriteServLog("AUTH_IA: Reloaded InetAccess successfully.");
+return 0;
+}
+//-----------------------------------------------------------------------------
int AUTH_IA::PrepareNet()
{
struct sockaddr_in listenAddr;
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms);
bool IsRunning() { return isRunningRunTimeouter || isRunningRun; }
const std::string & GetStrError() const { return errorStr; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning();
void SetSettings(const MODULE_SETTINGS & s);
int ParseSettings();
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
int ParseSettings() { return 0; }
bool IsRunning();
const std::string & GetStrError() const;
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return runningTCP || runningUDP; }
const std::string & GetStrError() const { return errorStr; }
std::string GetVersion() const { return VERSION; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
int ParseSettings() { return 0; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
int ParseSettings() { return 0; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return running && !stopped; }
const std::string & GetStrError() const { return errorStr; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
const std::string & GetStrError() const { return errorStr; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning();
const std::string & GetStrError() const { return errorStr; }
int Start();
int Stop();
- int Reload() { return 0; }
+ int Reload(const MODULE_SETTINGS & ms) { return 0; }
bool IsRunning() { return isRunning; }
const std::string & GetStrError() const { return errorStr; }
return 0;
}
//-----------------------------------------------------------------------------
-int REMOTE_SCRIPT::Reload()
+int REMOTE_SCRIPT::Reload(const MODULE_SETTINGS & ms)
{
NRMapParser nrMapParser;
int Start();
int Stop();
- int Reload();
+ int Reload(const MODULE_SETTINGS & ms);
bool IsRunning() { return isRunning; }
const std::string & GetStrError() const { return errorStr; }
return 0;
}
-int SMUX::Reload()
+int SMUX::Reload(const MODULE_SETTINGS & ms)
{
if (Stop())
return -1;
int Start();
int Stop();
- int Reload();
+ int Reload(const MODULE_SETTINGS & ms);
bool IsRunning() { return running && !stopped; }
const std::string & GetStrError() const { return errorStr; }
{
}
//-----------------------------------------------------------------------------
+SETTINGS_IMPL & SETTINGS_IMPL::operator=(const SETTINGS_IMPL & set)
+{
+ modulesPath = set.modulesPath;
+ dirName = set.dirName;
+ confDir = set.confDir;
+ scriptsDir = set.scriptsDir;
+ rules = set.rules;
+ logFile = set.logFile;
+ pidFile = set.pidFile;
+ monitorDir = set.monitorDir;
+ scriptParams = set.scriptParams;
+ monitoring = set.monitoring;
+ detailStatWritePeriod = set.detailStatWritePeriod;
+ statWritePeriod = set.statWritePeriod;
+ stgExecMsgKey = set.stgExecMsgKey;
+ executersNum = set.executersNum;
+ fullFee = set.fullFee;
+ dayFee = set.dayFee;
+ dayResetTraff = set.dayResetTraff;
+ spreadFee = set.spreadFee;
+ freeMbAllowInet = set.freeMbAllowInet;
+ dayFeeIsLastDay = set.dayFeeIsLastDay;
+ writeFreeMbTraffCost = set.writeFreeMbTraffCost;
+ showFeeInCash = set.showFeeInCash;
+ messageTimeout = set.messageTimeout;
+ feeChargeType = set.feeChargeType;
+ reconnectOnTariffChange = set.reconnectOnTariffChange;
+
+ modulesSettings = set.modulesSettings;
+ storeModuleSettings = set.storeModuleSettings;
+ return *this;
+}
+//-----------------------------------------------------------------------------
int SETTINGS_IMPL::ParseModuleSettings(const DOTCONFDocumentNode * node, std::vector<PARAM_VALUE> * params)
{
const DOTCONFDocumentNode * childNode;
#include "stg/settings.h"
#include "stg/common.h"
-#include "stg/logger.h"
#include "stg/module_settings.h"
//-----------------------------------------------------------------------------
SETTINGS_IMPL(const std::string &);
SETTINGS_IMPL(const SETTINGS_IMPL &);
virtual ~SETTINGS_IMPL() {}
+ SETTINGS_IMPL & operator=(const SETTINGS_IMPL &);
+
int Reload() { return ReadSettings(); }
int ReadSettings();