version 1.79.2.3, 2003/02/06 20:47:03
|
version 1.80, 2002/10/29 22:19:55
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
/***** |
|
| |
<< Fri Oct 11 15:47:00 2002 mdd >> |
////////////////////////////////////////////////////////////////////// |
|
// |
changed the shutdown option in lines 247-269 to use the local AF_INET interface |
// Notes on deamon operation (Unix) and service operation (Win 32): |
instead of unix domain sockets |
// |
|
// 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 |
|
// |
|
////////////////////////////////////////////////////////////////////// |
| |
*****/ |
|
| |
#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 |
|
|
usage.append (" -v - displays CIM Server version number\n"); | usage.append (" -v - displays CIM Server version number\n"); |
usage.append (" -h - prints this help message\n"); | usage.append (" -h - prints this help message\n"); |
usage.append (" -s - shuts down CIM Server\n"); | usage.append (" -s - shuts down CIM Server\n"); |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
usage.append (" -D [home] - sets pegasus home directory\n"); | usage.append (" -D [home] - sets pegasus home directory\n"); |
#endif | #endif |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
|
|
usage.append (" - sets CIM Server configuration property\n"); | usage.append (" - sets CIM Server configuration property\n"); |
| |
cout << endl; | cout << endl; |
#if defined(PEGASUS_OS_HPUX) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl; | cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl; |
#else | #else |
cout << PEGASUS_NAME << PEGASUS_VERSION << endl; | cout << PEGASUS_NAME << PEGASUS_VERSION << endl; |
|
|
// 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 |
{ | { |
// use the local port only. |
client.connectLocal(); |
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 more than the shutdown timeout |
// set client timeout to 2 seconds |
// so that the command client does not timeout before the cimserver |
|
// terminates |
|
// | // |
client.setTimeout( (timeoutValue+2)*1000 ); |
client.setTimeout(2000); |
} | } |
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; |
} | } |
| |
|
|
// | // |
if (*option == OPTION_VERSION) | if (*option == OPTION_VERSION) |
{ | { |
#if defined(PEGASUS_OS_HPUX) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << PLATFORM_PRODUCT_VERSION << endl; | cout << PLATFORM_PRODUCT_VERSION << endl; |
#else | #else |
cout << PEGASUS_VERSION << endl; | cout << PEGASUS_VERSION << endl; |
|
|
PrintHelp(argv[0]); | PrintHelp(argv[0]); |
exit(0); | exit(0); |
} | } |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
else if (*option == OPTION_HOME) | else if (*option == OPTION_HOME) |
{ | { |
if (i + 1 < argc) | if (i + 1 < argc) |
|
|
// Might be more logical to clean before set. | // Might be more logical to clean before set. |
// ATTN: Need tool to completely disable logging. | // ATTN: Need tool to completely disable logging. |
| |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
Logger::setHomeDirectory(logsDirectory); | Logger::setHomeDirectory(logsDirectory); |
#endif | #endif |
| |
|
|
httpsPort = configManager->getCurrentValue("httpsPort"); | httpsPort = configManager->getCurrentValue("httpsPort"); |
| |
// Leave this in until people get familiar with the logs. | // Leave this in until people get familiar with the logs. |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << "Logs Directory = " << logsDirectory << endl; | cout << "Logs Directory = " << logsDirectory << endl; |
#endif | #endif |
| |
|
|
} | } |
| |
// Put out startup up message. | // Put out startup up message. |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << PEGASUS_NAME << PEGASUS_VERSION << | cout << PEGASUS_NAME << PEGASUS_VERSION << |
" on port " << address << endl; | " on port " << address << endl; |
cout << "Built " << __DATE__ << " " << __TIME__ << endl; | cout << "Built " << __DATE__ << " " << __TIME__ << endl; |
|
|
// bind throws an exception if the bind fails | // bind throws an exception if the bind fails |
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET | #ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
cout << "Binding to domain socket" << endl; | cout << "Binding to domain socket" << endl; |
#elif !defined(PEGASUS_OS_HPUX) |
#elif !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << "Binding to " << address << endl; | cout << "Binding to " << address << endl; |
#endif | #endif |
| |
|
|
fclose(pid_file); | fclose(pid_file); |
} | } |
#endif | #endif |
#ifndef PEGASUS_OS_HPUX |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << "Started. " << endl; | cout << "Started. " << endl; |
#endif | #endif |
| |
// Put server started message to the logger | // Put server started message to the logger |
#ifdef PEGASUS_OS_HPUX |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"Started $0 version $1 on port $2.", | "Started $0 version $1 on port $2.", |
PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION, address); | PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION, address); |
|
|
// 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( false == server.terminated() ) |
while( !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; |
} | } |