#include "stg/plugin.h"
#include "stg/logger.h"
#include "stg/scriptexecuter.h"
-#include "stg/conffiles.h"
#include "stg/version.h"
-#include "stg/pinger.h"
#include "stg_timer.h"
#include "settings_impl.h"
#include "users_impl.h"
#define START_FILE "/._ST_ART_ED_"
set<pid_t> executersPid;
-static pid_t stgChildPid;
//-----------------------------------------------------------------------------
bool StartModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs)
}
}
//-----------------------------------------------------------------------------
+#ifdef LINUX
int StartScriptExecuter(char * procName, int msgKey, int * msgID, SETTINGS_IMPL * settings)
+#else
+int StartScriptExecuter(char *, int msgKey, int * msgID, SETTINGS_IMPL * settings)
+#endif
{
STG_LOGGER & WriteServLog = GetStgLogger();
case 0:
delete settings;
+#ifdef LINUX
Executer(*msgID, executerPid, procName);
+#else
+ Executer(*msgID, executerPid);
+#endif
return 1;
default:
if (executersPid.empty()) {
+#ifdef LINUX
Executer(*msgID, executerPid, NULL);
+#else
+ Executer(*msgID, executerPid);
+#endif
}
executersPid.insert(executerPid);
}
#endif
{
#ifndef NO_DAEMON
-stgChildPid = fork();
+pid_t childPid = fork();
string startFile = confDir + START_FILE;
unlink(startFile.c_str());
-switch (stgChildPid)
+switch (childPid)
{
case -1:
return -1;
PIDFile pidFile(settings->GetPIDFileName());
+sigset_t signalSet;
+sigfillset(&signalSet);
+pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
+
StartTimer();
WaitTimer();
if (!IsStgTimerRunning())
{
if (modIter->Load())
{
- WriteServLog("Error: %s",
+ WriteServLog("Error loading module '%s': %s",
+ modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
goto exitLblNotStarted;
}
{
if (modIter->Start())
{
- WriteServLog("Error: %s",
+ WriteServLog("Error starting module '%s': %s",
+ modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
goto exitLbl;
}
while (true)
{
- sigset_t signalSet;
sigfillset(&signalSet);
int sig = 0;
sigwait(&signalSet, &sig);
{
if (modIter->Reload())
{
- WriteServLog("Error reloading %s ('%s')", modIter->GetPlugin()->GetVersion().c_str(),
+ WriteServLog("Error reloading module '%s': '%s'", modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
- printfd(__FILE__, "Error reloading %s ('%s')\n", modIter->GetPlugin()->GetVersion().c_str(),
+ printfd(__FILE__, "Error reloading module '%s': '%s'\n", modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
}
}
printfd(__FILE__, "Stopping module '%s'\n", name.c_str());
if (modIter->Stop())
{
- WriteServLog("Module \'%s\': Error: %s",
+ WriteServLog("Error stopping module '%s': %s",
modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
- printfd(__FILE__, "Failed to stop module '%s'\n", name.c_str());
+ printfd(__FILE__, "Error stopping module '%s': '%s'\n", modIter->GetPlugin()->GetVersion().c_str(), modIter->GetStrError().c_str());
+ }
+ else
+ {
+ WriteServLog("Module: '%s'. Stop successfull.", modIter->GetPlugin()->GetVersion().c_str());
}
- WriteServLog("Module: \'%s\'. Stop successfull.", modIter->GetPlugin()->GetVersion().c_str());
++modIter;
}
printfd(__FILE__, "Unloading module '%s'\n", name.c_str());
if (modIter->Unload())
{
- WriteServLog("Module \'%s\': Error: %s",
- name.c_str(),
+ WriteServLog("Error unloading module '%s': '%s'",
+ modIter->GetPlugin()->GetVersion().c_str(),
modIter->GetStrError().c_str());
- printfd(__FILE__, "Failed to unload module '%s'\n", name.c_str());
+ printfd(__FILE__, "Error unloading module '%s': '%s'\n", modIter->GetPlugin()->GetVersion().c_str(), modIter->GetStrError().c_str());
}
}
++modIter;