2009-02-09 Esteban Sanchez <estebans@artica.es>

* main.cc: Added a new parameter --process to run the agent as a
        single process instead of a service.

        * pandora_windows_service.h: Interval property is now public so it can
        be readed if it's running as a single process.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1432 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2009-02-09 10:26:07 +00:00
parent ef32f64adf
commit 19ebb674a5
3 changed files with 116 additions and 95 deletions

View File

@ -1,3 +1,11 @@
2009-02-09 Esteban Sanchez <estebans@artica.es>
* main.cc: Added a new parameter --process to run the agent as a
single process instead of a service.
* pandora_windows_service.h: Interval property is now public so it can
be readed if it's running as a single process.
2008-12-03 Esteban Sanchez <estebans@artica.es>
* bin/PandoraAgent.exe: Updated to last commit.

View File

@ -29,6 +29,7 @@
#define SSH_TEST_CMDLINE_PARAM "--test-ssh"
#define FTP_TEST_CMDLINE_PARAM "--test-ftp"
#define HELP_CMDLINE_PARAM "--help"
#define PROCESS_CMDLINE_PARAM "--process"
int
main (int argc, char *argv[]) {
@ -36,6 +37,7 @@ main (int argc, char *argv[]) {
char buffer[PATH_SIZE];
string aux;
unsigned int pos;
bool process = false;
service = Pandora_Windows_Service::getInstance ();
service->setValues (Pandora::name, Pandora::display_name,
@ -91,8 +93,7 @@ main (int argc, char *argv[]) {
}
return 0;
} else if (_stricmp(argv[i], HELP_CMDLINE_PARAM) == 0) {
} else if (_stricmp(argv[i], HELP_CMDLINE_PARAM) == 0) {
/* Help parameter */
cout << "Pandora agent for Windows. ";
cout << "Version " << getPandoraAgentVersion () << endl;
@ -108,6 +109,8 @@ main (int argc, char *argv[]) {
cout << ": Test the FTP Pandora Agent configuration." << endl;
return 0;
} else if (_stricmp(argv[i], PROCESS_CMDLINE_PARAM) == 0) {
process = true;
} else {
/* No parameter recognized */
cout << "Pandora agent for Windows. ";
@ -123,7 +126,16 @@ main (int argc, char *argv[]) {
return 1;
}
}
service->run ();
if (process) {
cout << "Pandora agent is now running" << endl;
service->pandora_init ();
while (1) {
service->pandora_run ();
Sleep (service->interval / 1000);
}
} else {
service->run ();
}
delete service;

View File

@ -41,7 +41,6 @@ namespace Pandora {
Pandora_Module_List *modules;
long execution_number;
string agent_name;
long interval;
long elapsed_transfer_time;
long transfer_interval;
bool started;
@ -72,6 +71,8 @@ namespace Pandora {
public:
void pandora_run ();
void pandora_init ();
long interval;
public:
static Pandora_Windows_Service *getInstance ();