2009-10-15 Ramon Novoa <rnovoa@artica.es>
* windows_service.cc: Enable service recovery by default. * pandora_windows_service.cc: Added autotime, group and description configuration options. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2024 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b56c3d8ef7
commit
39cb7f8736
|
@ -1,3 +1,10 @@
|
||||||
|
2009-10-15 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* windows_service.cc: Enable service recovery by default.
|
||||||
|
|
||||||
|
* pandora_windows_service.cc: Added autotime, group and description
|
||||||
|
configuration options.
|
||||||
|
|
||||||
2009-10-13 Sancho Lerena <slerena@artica.es>
|
2009-10-13 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* bin/PandoraAgent.exe: Last build of agent binary.
|
* bin/PandoraAgent.exe: Last build of agent binary.
|
||||||
|
|
|
@ -189,17 +189,23 @@ Pandora_Windows_Service::getXmlHeader () {
|
||||||
}
|
}
|
||||||
agent->SetAttribute ("agent_name", value);
|
agent->SetAttribute ("agent_name", value);
|
||||||
|
|
||||||
|
value = conf->getValue ("description");
|
||||||
|
agent->SetAttribute ("description", value);
|
||||||
|
|
||||||
agent->SetAttribute ("version", getPandoraAgentVersion ());
|
agent->SetAttribute ("version", getPandoraAgentVersion ());
|
||||||
|
|
||||||
// Get current time
|
// Get current time
|
||||||
ctime = time(0);
|
ctime = time(0);
|
||||||
ctime_tm = localtime(&ctime);
|
ctime_tm = localtime(&ctime);
|
||||||
|
|
||||||
sprintf (timestamp, "%d-%02d-%02d %02d:%02d:%02d", ctime_tm->tm_year + 1900,
|
value = conf->getValue ("autotime");
|
||||||
ctime_tm->tm_mon + 1, ctime_tm->tm_mday, ctime_tm->tm_hour,
|
if (value != "1") {
|
||||||
ctime_tm->tm_min, ctime_tm->tm_sec);
|
sprintf (timestamp, "%d-%02d-%02d %02d:%02d:%02d", ctime_tm->tm_year + 1900,
|
||||||
|
ctime_tm->tm_mon + 1, ctime_tm->tm_mday, ctime_tm->tm_hour,
|
||||||
|
ctime_tm->tm_min, ctime_tm->tm_sec);
|
||||||
|
|
||||||
agent->SetAttribute ("timestamp", timestamp);
|
agent->SetAttribute ("timestamp", timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
value = conf->getValue ("interval");
|
value = conf->getValue ("interval");
|
||||||
agent->SetAttribute ("interval", value);
|
agent->SetAttribute ("interval", value);
|
||||||
|
@ -210,6 +216,9 @@ Pandora_Windows_Service::getXmlHeader () {
|
||||||
value = value + Pandora_Windows_Info::getOSVersion ();
|
value = value + Pandora_Windows_Info::getOSVersion ();
|
||||||
agent->SetAttribute ("os_version", value);
|
agent->SetAttribute ("os_version", value);
|
||||||
|
|
||||||
|
value = conf->getValue ("group");
|
||||||
|
agent->SetAttribute ("group", value);
|
||||||
|
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,8 @@ void
|
||||||
Windows_Service::install (LPCTSTR application_binary_path) {
|
Windows_Service::install (LPCTSTR application_binary_path) {
|
||||||
SC_HANDLE sc_manager;
|
SC_HANDLE sc_manager;
|
||||||
SERVICE_DESCRIPTION sd_buf;
|
SERVICE_DESCRIPTION sd_buf;
|
||||||
|
SERVICE_FAILURE_ACTIONS fa;
|
||||||
|
SC_ACTION sa[2];
|
||||||
|
|
||||||
cout << " [SERVICE] Attempting to install the service.\n";
|
cout << " [SERVICE] Attempting to install the service.\n";
|
||||||
cout << " [SERVICE] The full path to the binary is: " << application_binary_path << endl;
|
cout << " [SERVICE] The full path to the binary is: " << application_binary_path << endl;
|
||||||
|
@ -276,6 +278,23 @@ Windows_Service::install (LPCTSTR application_binary_path) {
|
||||||
cout << " [SERVICE] Unable to add a description to the service. " << msg << endl;
|
cout << " [SERVICE] Unable to add a description to the service. " << msg << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enable service recovery */
|
||||||
|
fa.dwResetPeriod = 86400; // One day
|
||||||
|
fa.lpRebootMsg = NULL;
|
||||||
|
fa.lpCommand = NULL;
|
||||||
|
fa.cActions = 2;
|
||||||
|
sa[0].Delay = 300000; // One minute
|
||||||
|
sa[0].Type = SC_ACTION_RESTART;
|
||||||
|
sa[1].Delay = 0;
|
||||||
|
sa[1].Type = SC_ACTION_NONE;
|
||||||
|
fa.lpsaActions = sa;
|
||||||
|
if (!ChangeServiceConfig2 (sc_service, SERVICE_CONFIG_FAILURE_ACTIONS, &fa)) {
|
||||||
|
TCHAR msg[1000];
|
||||||
|
|
||||||
|
svc_format_message (msg, sizeof (msg));
|
||||||
|
cout << " [SERVICE] Service recovery could not be enabled. " << msg << endl;
|
||||||
|
}
|
||||||
|
|
||||||
cout << " [SERVICE] Successfully added the service to the Services database." << endl;
|
cout << " [SERVICE] Successfully added the service to the Services database." << endl;
|
||||||
|
|
||||||
CloseServiceHandle (sc_service);
|
CloseServiceHandle (sc_service);
|
||||||
|
|
Loading…
Reference in New Issue