version 1.79, 2002/10/15 21:41:03
|
version 1.79.2.3, 2003/02/06 20:47:03
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
/***** |
| |
////////////////////////////////////////////////////////////////////// |
<< Fri Oct 11 15:47:00 2002 mdd >> |
// |
|
// Notes on deamon operation (Unix) and service operation (Win 32): |
|
// |
|
// To run pegasus as a daemon on Unix platforms: |
|
// |
|
// cimserver |
|
// |
|
// To NOT run pegasus as a daemon on Unix platforms, set the daemon config |
|
// property to false: |
|
// |
|
// cimserver daemon=false |
|
// |
|
// The daemon config property has no effect on windows operation. |
|
// |
|
// To shutdown pegasus, use the -s option: |
|
// |
|
// cimserver -s |
|
// |
|
// To run pegasus as an NT service, there are FOUR different possibilities: |
|
// |
|
// To INSTALL the Pegasus service, |
|
// |
|
// cimserver -install |
|
// |
|
// To REMOVE the Pegasus service, |
|
// |
|
// cimserver -remove |
|
// |
|
// To START the Pegasus service, |
|
// |
|
// net start cimserver |
|
// |
|
// To STOP the Pegasus service, |
|
// |
|
// net stop cimserver |
|
// |
|
// Alternatively, you can use the windows service manager. Pegasus shows up |
|
// in the service database as "Pegasus CIM Object Manager" |
|
// |
|
// Mike Day, mdday@us.ibm.com |
|
// |
|
////////////////////////////////////////////////////////////////////// |
|
| |
|
changed the shutdown option in lines 247-269 to use the local AF_INET interface |
|
instead of unix domain sockets |
|
|
|
*****/ |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Constants.h> | #include <Pegasus/Common/Constants.h> |
|
|
static const String PROPERTY_TIMEOUT = "shutdownTimeout"; | static const String PROPERTY_TIMEOUT = "shutdownTimeout"; |
static const String CIMSERVERSTART_FILE = "/etc/opt/wbem/cimserver_start.conf"; | static const String CIMSERVERSTART_FILE = "/etc/opt/wbem/cimserver_start.conf"; |
| |
|
|
ConfigManager* configManager; | ConfigManager* configManager; |
| |
/** GetOptions function - This function defines the Options Table | /** GetOptions function - This function defines the Options Table |
|
|
// Get local host name | // Get local host name |
// | // |
String hostStr = System::getHostName(); | String hostStr = System::getHostName(); |
|
hostStr.append(":"); |
| |
|
if (String::equal(configManager->getCurrentValue("SSL"), "true")) |
|
{ |
|
hostStr.append(configManager->getCurrentValue("httpsPort")); |
|
} |
|
else |
|
{ |
|
hostStr.append(configManager->getCurrentValue("httpPort")); |
|
} |
// | // |
// open connection to CIMOM | // open connection to CIMOM |
// | // |
try | try |
{ | { |
client.connectLocal(); |
// use the local port only. |
|
String addr("127.0.0.1:"); |
|
if (String::equal(configManager->getCurrentValue("SSL"), "true")) |
|
{ |
|
addr.append(configManager->getCurrentValue("httpsPort")); |
|
} |
|
else |
|
{ |
|
addr.append(configManager->getCurrentValue("httpPort")); |
|
} |
|
|
|
// use localPrivilegedOnly instead |
|
client.connect(addr); |
| |
// | // |
// set client timeout to 2 seconds |
// set client timeout to 2 seconds more than the shutdown timeout |
|
// so that the command client does not timeout before the cimserver |
|
// terminates |
// | // |
client.setTimeout(2000); |
client.setTimeout( (timeoutValue+2)*1000 ); |
} | } |
|
catch(Exception &) |
|
{ |
|
try |
|
{ |
|
client.connectLocal(); |
|
} |
|
|
catch(Exception& e) | catch(Exception& e) |
{ | { |
PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl); |
|
|
#endif | #endif |
exit(0); | exit(0); |
} | } |
|
} |
| |
try | try |
{ | { |
|
|
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |
|
|
// | // |
// This may mean the CIM Server has been terminated and returns a | // This may mean the CIM Server has been terminated and returns a |
// "Empty HTTP response message" HTTP error response. To be sure | // "Empty HTTP response message" HTTP error response. To be sure |
|
|
// | // |
// give CIM Server some time to finish up | // give CIM Server some time to finish up |
// | // |
//System::sleep(1); |
System::sleep(1); |
//cimserver_kill(); |
cimserver_kill(); |
| |
// | // |
// Check to see if CIMServer is still running. If CIMServer | // Check to see if CIMServer is still running. If CIMServer |
|
|
cimserver_kill(); | cimserver_kill(); |
} | } |
} | } |
//catch(Exception& e) |
|
//{ |
|
// PEGASUS_STD(cerr) << "Error occurred while stopping the CIM Server: "; |
|
// PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl); |
|
// exit(1); |
|
//} |
|
|
|
return; | return; |
} | } |
| |
|
|
// Loop to call CIMServer's runForever() method until CIMServer | // Loop to call CIMServer's runForever() method until CIMServer |
// has been shutdown | // has been shutdown |
// | // |
while( !server.terminated() ) |
while( false == server.terminated() ) |
{ | { |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) | #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
if(useSLP ) | if(useSLP ) |
|
|
| |
return 1; | return 1; |
} | } |
|
#if defined(PEGASUS_OS_TYPE_UNIX) |
|
kill(getpid(), SIGKILL); |
|
#endif |
|
#if defined(PEGASUS_OS_TYPE_WINDOWS) |
|
ExitProcess(0); |
|
#endif |
|
_exit(1); |
return 0; | return 0; |
} | } |