2009-02-24 Ramon Novoa <rnovoa@artica.es>

* win32/modules/pandora_module_proc.cc,
          win32/modules/pandora_module_proc.h,
          win32/modules/pandora_module_factory.cc,
          win32/pandora_windows_service.cc: Fixed some 'work in progress'
          code from previous commit.

        * win32/pandora.cc: Updated version string.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1482 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2009-02-24 18:50:16 +00:00
parent 148769b57c
commit 2c6d6d5954
6 changed files with 56 additions and 32 deletions

View File

@ -1,3 +1,13 @@
2009-02-24 Ramon Novoa <rnovoa@artica.es>
* win32/modules/pandora_module_proc.cc,
win32/modules/pandora_module_proc.h,
win32/modules/pandora_module_factory.cc,
win32/pandora_windows_service.cc: Fixed some 'work in progress'
code from previous commit.
* win32/pandora.cc: Updated version string.
2009-02-24 Jorge Gonzalez <jorgegonz@svn.gnome.org> 2009-02-24 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* linux/pandora_agent.conf: fixed typo. * linux/pandora_agent.conf: fixed typo.

View File

@ -101,6 +101,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_pattern, module_async; string module_pattern, module_async;
string module_watchdog, module_start_command; string module_watchdog, module_start_command;
string module_wmiquery, module_wmicolumn; string module_wmiquery, module_wmicolumn;
string module_retries, module_startdelay, module_retrydelay;
Pandora_Module *module; Pandora_Module *module;
bool numeric; bool numeric;
Module_Type type; Module_Type type;
@ -250,9 +251,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_proc = (Pandora_Module_Proc *) module; module_proc = (Pandora_Module_Proc *) module;
module_proc->setWatchdog (true); module_proc->setWatchdog (true);
module_proc->setStartCommand (module_start_command); module_proc->setStartCommand (module_start_command);
module_proc->setRetries (atoi(module_retries)); module_proc->setRetries (atoi(module_retries.c_str ()));
module_proc->setStartDelay (atoi(module_startdelay)); module_proc->setStartDelay (atoi(module_startdelay.c_str ()));
module_proc->setRetryDelay (atoi(module_retrydelay)); module_proc->setRetryDelay (atoi(module_retrydelay.c_str ()));
} }
} }
} else if (module_service != "") { } else if (module_service != "") {

View File

@ -80,8 +80,8 @@ Pandora_Module_Proc::getStartDelay () const {
} }
int int
Pandora_Module_Proc::getStopDelay () const { Pandora_Module_Proc::getRetryDelay () const {
return this->stop_delay; return this->retry_delay;
} }
void void
@ -107,7 +107,8 @@ Pandora_Module_Proc::setStartDelay (int mseconds) {
if (mseconds < MIN_DELAY) { if (mseconds < MIN_DELAY) {
return; return;
} }
this->start_delay = start_delay;
this->start_delay = mseconds;
} }
void void
@ -115,7 +116,8 @@ Pandora_Module_Proc::setRetryDelay (int mseconds) {
if (mseconds < MIN_DELAY) { if (mseconds < MIN_DELAY) {
return; return;
} }
this->retry_delay = retry_delay;
this->retry_delay = mseconds;
} }
void void
@ -131,20 +133,27 @@ async_run (Pandora_Module_Proc *module) {
prev_res = module->getLatestOutput (); prev_res = module->getLatestOutput ();
modules = new Pandora_Module_List (); modules = new Pandora_Module_List ();
modules->addModule (module); modules->addModule (module);
Sleep (this->getStartDelay ()); Sleep (module->getStartDelay ());
while (1) { while (1) {
Sleep (module->getStartDelay ());
processes = getProcessHandles (module->getProcessName ()); processes = getProcessHandles (module->getProcessName ());
if (processes == NULL) { if (processes == NULL) {
if (module->isWatchdog ()) { if (module->isWatchdog ()) {
if (counter >= this->getRetries ()) { if (counter >= module->getRetries ()) {
this->setWatchdog (false); module->setWatchdog (false);
} else { continue;
Pandora_Wmi::runProgram (module->getStartCommand ());
counter++;
} }
/* Retrying... */
if (counter > 0) {
Sleep (module->getRetryDelay ());
}
Pandora_Wmi::runProgram (module->getStartCommand ());
counter++;
} }
Sleep (this->getStartDelay ()); Sleep (module->getRetryDelay ());
continue; continue;
} }
@ -185,8 +194,6 @@ async_run (Pandora_Module_Proc *module) {
for (i = 0; i < nprocess; i++) for (i = 0; i < nprocess; i++)
CloseHandle (processes[i]); CloseHandle (processes[i]);
pandoraFree (processes); pandoraFree (processes);
Sleep (this->getRetryDelay ());
} }
delete modules; delete modules;

View File

@ -31,24 +31,24 @@ namespace Pandora_Modules {
*/ */
class Pandora_Module_Proc : public Pandora_Module { class Pandora_Module_Proc : public Pandora_Module {
private: private:
string process_name; string process_name;
HANDLE thread; HANDLE thread;
bool watchdog; bool watchdog;
string start_command; string start_command;
int retries; int retries;
int start_delay; int start_delay;
int stop_delay; int retry_delay;
public: public:
Pandora_Module_Proc (string name, string process_name); Pandora_Module_Proc (string name, string process_name);
string getProcessName () const; string getProcessName () const;
string getStartCommand () const; string getStartCommand () const;
bool isWatchdog () const; bool isWatchdog () const;
int getRetries () const; int getRetries () const;
int getStartDelay () const; int getStartDelay () const;
void getRetryDelay () const; int getRetryDelay () const;
void setWatchdog (bool watchdog); void setWatchdog (bool watchdog);
void setStartCommand (string command); void setStartCommand (string command);
void setRetries (int retries); void setRetries (int retries);
void setStartDelay (int mseconds); void setStartDelay (int mseconds);

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("2.0(Build 080610)") #define PANDORA_VERSION ("3.0(Build 090224)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -209,8 +209,10 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
{ {
bool rc = false; bool rc = false;
string var, filepath; string var, filepath;
string tentacle_cmd; string tentacle_cmd, working_dir;
PROCESS_INFORMATION pi;
STARTUPINFO si;
var = conf->getValue ("temporal"); var = conf->getValue ("temporal");
if (var[var.length () - 1] != '\\') { if (var[var.length () - 1] != '\\') {
var += "\\"; var += "\\";
@ -244,11 +246,15 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
filepath.c_str (), host.c_str ()); filepath.c_str (), host.c_str ());
pandoraDebug ("Command %s", tentacle_cmd.c_str()); pandoraDebug ("Command %s", tentacle_cmd.c_str());
rc = Pandora_Wmi::runProgram (tentacle_cmd.c_str(), CREATE_NO_WINDOW); ZeroMemory (&si, sizeof (si));
ZeroMemory (&pi, sizeof (pi));
rc = CreateProcess (NULL , (CHAR *)tentacle_cmd.c_str (), NULL, NULL, FALSE, CREATE_NO_WINDOW,
NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
if (rc == true) { if (rc == true) {
return 0; return 0;
} }
pandoraDebug ("Tentacle client was unable to copy %s", pandoraDebug ("Tentacle client was unable to copy %s",
filename.c_str ()); filename.c_str ());
return -1; return -1;