version 1.71, 2002/09/05 21:15:03
|
version 1.79, 2002/10/15 21:41:03
|
|
|
// Modified By: Jenny Yu (jenny_yu@hp.com) | // Modified By: Jenny Yu (jenny_yu@hp.com) |
// | // |
// Modified By: Sushma Fernandes (sushma_fernandes@hp.com) | // Modified By: Sushma Fernandes (sushma_fernandes@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Client/CIMClient.h> | #include <Pegasus/Client/CIMClient.h> |
#include <Pegasus/Server/ShutdownService.h> | #include <Pegasus/Server/ShutdownService.h> |
#include <Pegasus/Common/Destroyer.h> | #include <Pegasus/Common/Destroyer.h> |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
#include <slp/slp.h> | #include <slp/slp.h> |
#endif | #endif |
| |
|
|
String referenceStr = "//"; | String referenceStr = "//"; |
referenceStr.append(hostStr); | referenceStr.append(hostStr); |
referenceStr.append("/"); | referenceStr.append("/"); |
referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN); |
referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString()); |
referenceStr.append(":"); | referenceStr.append(":"); |
referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN); |
referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString()); |
CIMObjectPath reference(referenceStr); | CIMObjectPath reference(referenceStr); |
| |
// | // |
|
|
useSLP = true; | useSLP = true; |
} | } |
| |
|
#if defined(PEGASUS_USE_RELEASE_CONFIG_OPTIONS) |
|
Boolean enableHttpConnection = String::equal( |
|
configManager->getCurrentValue("enableHttpConnection"), "true"); |
|
Boolean enableHttpsConnection = String::equal( |
|
configManager->getCurrentValue("enableHttpsConnection"), "true"); |
|
|
|
if (enableHttpConnection && enableHttpsConnection) |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
"Enabling both HTTP and HTTPS connections is unsupported. " |
|
"Only the HTTPS connection is enabled."); |
|
cerr << "Enabling both HTTP and HTTPS connections is unsupported. " |
|
"Only the HTTPS connection is enabled." << endl; |
|
} |
|
else if (!enableHttpConnection && !enableHttpsConnection) |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
"Neither HTTP nor HTTPS connection is enabled. " |
|
"CIMServer will not be started."); |
|
cerr << "Neither HTTP nor HTTPS connection is enabled. " |
|
"CIMServer will not be started." << endl; |
|
exit(1); |
|
} |
|
|
|
useSSL = enableHttpsConnection; |
|
|
|
#else |
if (String::equal(configManager->getCurrentValue("SSL"), "true")) | if (String::equal(configManager->getCurrentValue("SSL"), "true")) |
{ | { |
useSSL = true; | useSSL = true; |
} | } |
|
#endif |
} | } |
catch (UnrecognizedConfigProperty e) | catch (UnrecognizedConfigProperty e) |
{ | { |
|
|
| |
#ifdef PEGASUS_OS_HPUX | #ifdef PEGASUS_OS_HPUX |
umask(S_IWGRP|S_IWOTH); | umask(S_IWGRP|S_IWOTH); |
|
|
|
// |
|
// check if CIMServer is already running |
|
// if CIMServer is already running, print message and |
|
// notify parent process (if there is a parent process) to terminate |
|
// |
|
if(isCIMServerRunning()) |
|
{ |
|
cout << "Unable to start CIMServer." << endl; |
|
cout << "CIMServer is already running." << endl; |
|
|
|
// |
|
// notify parent process (if there is a parent process) to terminate |
|
// |
|
if (daemonOption) |
|
notify_parent(); |
|
|
|
exit(1); |
|
} |
|
|
#endif | #endif |
| |
// try loop to bind the address, and run the server | // try loop to bind the address, and run the server |
try | try |
{ | { |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
slp_client *discovery = new slp_client() ;; | slp_client *discovery = new slp_client() ;; |
String serviceURL; | String serviceURL; |
serviceURL.assign("service:cim.pegasus://"); | serviceURL.assign("service:cim.pegasus://"); |
|
|
| |
server.bind(portNumber); | server.bind(portNumber); |
| |
|
// notify parent process (if there is a parent process) to terminate |
|
// so user knows that cimserver is ready to serve CIM requests. |
|
if (daemonOption) |
|
notify_parent(); |
|
|
time_t last = 0; | time_t last = 0; |
| |
#if defined(PEGASUS_OS_HPUX) | #if defined(PEGASUS_OS_HPUX) |
|
|
// | // |
while( !server.terminated() ) | while( !server.terminated() ) |
{ | { |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
if(useSLP ) | if(useSLP ) |
{ | { |
if( (time(NULL) - last ) > 60 ) | if( (time(NULL) - last ) > 60 ) |
|
|
catch(Exception& e) | catch(Exception& e) |
{ | { |
PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); |
|
|
|
// |
|
// notify parent process (if there is a parent process) to terminate |
|
// |
|
if (daemonOption) |
|
notify_parent(); |
|
|
return 1; | return 1; |
} | } |
| |