version 1.31, 2007/06/05 10:25:03
|
version 1.35, 2007/07/02 01:47:05
|
|
|
#include <Pegasus/Common/PegasusAssert.h> | #include <Pegasus/Common/PegasusAssert.h> |
#include <fstream> | #include <fstream> |
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Monitor.h> |
|
#include <Pegasus/Common/PegasusVersion.h> | #include <Pegasus/Common/PegasusVersion.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
|
|
return PEGASUS_PROCESS_NAME; | return PEGASUS_PROCESS_NAME; |
} | } |
| |
//defined in Constants.h |
int cimserver_run( |
virtual const char* getPIDFileName() const |
int argc, |
{ |
char** argv, |
return PEGASUS_CIMSERVER_START_FILE; |
Boolean shutdownOption, |
} |
Boolean debugOutputOption); |
|
|
int cimserver_run(int argc, char** argv, bool shutdownOption); |
|
| |
void cimserver_stop(void); | void cimserver_stop(void); |
}; | }; |
|
|
PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE); | PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE); |
AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess()); | AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess()); |
static CIMServer* _cimServer = 0; | static CIMServer* _cimServer = 0; |
static Monitor* _monitor = 0; |
|
| |
// | // |
// The command name. | // The command name. |
|
|
static const char OPTION_BINDVERBOSE = 'X'; | static const char OPTION_BINDVERBOSE = 'X'; |
#endif | #endif |
| |
static const String PROPERTY_TIMEOUT = "shutdownTimeout"; |
|
|
|
ConfigManager* configManager; |
|
|
|
/** GetOptions function - This function defines the Options Table | /** GetOptions function - This function defines the Options Table |
and sets up the options from that table using the config manager. | and sets up the options from that table using the config manager. |
| |
|
|
//We need to delete the _cimServer reference on exit in order for the destructors to get called. | //We need to delete the _cimServer reference on exit in order for the destructors to get called. |
void deleteCIMServer() | void deleteCIMServer() |
{ | { |
if (_cimServer) |
|
{ |
|
delete _cimServer; | delete _cimServer; |
_cimServer = 0; | _cimServer = 0; |
} | } |
| |
if (_monitor) |
|
{ |
|
delete _monitor; |
|
} |
|
} |
|
|
|
// l10n | // l10n |
// | // |
// Dummy function for the Thread object associated with the initial thread. | // Dummy function for the Thread object associated with the initial thread. |
|
|
{ | { |
String pegasusHome; | String pegasusHome; |
Boolean shutdownOption = false; | Boolean shutdownOption = false; |
|
Boolean debugOutputOption = false; |
| |
//l10n | //l10n |
// Set Message loading to process locale | // Set Message loading to process locale |
|
|
// Do the plaform specific run | // Do the plaform specific run |
// | // |
| |
return _cimServerProcess->platform_run( argc, argv, shutdownOption ); |
return _cimServerProcess->platform_run( |
|
argc, argv, shutdownOption, debugOutputOption); |
} | } |
| |
void CIMServerProcess::cimserver_stop() | void CIMServerProcess::cimserver_stop() |
|
|
// specific runs may need to deal with bettter (instead of exit(), etc). | // specific runs may need to deal with bettter (instead of exit(), etc). |
// | // |
| |
int CIMServerProcess::cimserver_run( int argc, char** argv, Boolean shutdownOption ) |
int CIMServerProcess::cimserver_run( |
|
int argc, |
|
char** argv, |
|
Boolean shutdownOption, |
|
Boolean debugOutputOption) |
{ | { |
String logsDirectory; | String logsDirectory; |
Boolean daemonOption = false; | Boolean daemonOption = false; |
|
|
// | // |
// Get an instance of the Config Manager. | // Get an instance of the Config Manager. |
// | // |
configManager = ConfigManager::getInstance(); |
ConfigManager* configManager = ConfigManager::getInstance(); |
configManager->useConfigFiles = true; | configManager->useConfigFiles = true; |
| |
// | // |
|
|
#ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
if (!enableHttpConnection && !enableHttpsConnection) | if (!enableHttpConnection && !enableHttpsConnection) |
{ | { |
//l10n |
|
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
|
//"Neither HTTP nor HTTPS connection is enabled. " |
|
//"CIMServer will not be started."); |
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, | Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
"src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING", | "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING", |
"Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started."); |
"Neither HTTP nor HTTPS connection is enabled."); |
//cerr << "Neither HTTP nor HTTPS connection is enabled. " |
MessageLoaderParms parms( |
//"CIMServer will not be started." << endl; |
"src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING", |
MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING", |
"Neither HTTP nor HTTPS connection is enabled."); |
"Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started."); |
|
cerr << MessageLoader::getMessage(parms) << endl; | cerr << MessageLoader::getMessage(parms) << endl; |
return(1); |
return 1; |
} | } |
#endif | #endif |
| |
|
|
| |
#if defined(PEGASUS_DEBUG) | #if defined(PEGASUS_DEBUG) |
// Put out startup up message. | // Put out startup up message. |
cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getVersion() << endl; |
cout << _cimServerProcess->getProductName() << " " << |
//l10n |
_cimServerProcess->getVersion() << endl; |
//cout << "Built " << __DATE__ << " " << __TIME__ << endl; |
|
//cout <<"Starting..." |
|
MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE", |
|
"Built $0 $1\nStarting...", |
|
__DATE__, |
|
__TIME__); |
|
#endif | #endif |
| |
//l10n |
|
// reset message loading to NON-process locale | // reset message loading to NON-process locale |
MessageLoader::_useProcessLocale = false; | MessageLoader::_useProcessLocale = false; |
//l10n |
|
| |
// Get the parent's PID before forking | // Get the parent's PID before forking |
_serverRunStatus.setParentPid(System::getPID()); | _serverRunStatus.setParentPid(System::getPID()); |
|
|
// try loop to bind the address, and run the server | // try loop to bind the address, and run the server |
try | try |
{ | { |
_monitor = new Monitor(); |
_cimServer = new CIMServer(); |
_cimServer = new CIMServer(_monitor); |
|
| |
| |
if (enableHttpConnection) | if (enableHttpConnection) |
{ | { |
_cimServer->addAcceptor(false, portNumberHttp, false, false); |
#ifdef PEGASUS_ENABLE_IPV6 |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
|
portNumberHttp, false); |
|
#endif |
|
|
|
#if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS) |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
|
portNumberHttp, false); |
|
#endif |
| |
Logger::put_l( | Logger::put_l( |
Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
|
| |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
_cimServer->addAcceptor(false, portNumberHttps, true, false); |
#ifdef PEGASUS_ENABLE_IPV6 |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
|
portNumberHttps, true); |
|
#endif |
|
|
|
#if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS) |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
|
portNumberHttps, true); |
|
#endif |
| |
Logger::put_l( | Logger::put_l( |
Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
|
} | } |
| |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
_cimServer->addAcceptor(true, 0, false, false); |
_cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false); |
|
|
Logger::put_l( | Logger::put_l( |
Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
"src.Server.cimserver.LISTENING_ON_LOCAL", | "src.Server.cimserver.LISTENING_ON_LOCAL", |
|
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, | Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, |
Logger::INFORMATION, "src.Server.cimserver.STOPPED", | Logger::INFORMATION, "src.Server.cimserver.STOPPED", |
"$0 stopped.", _cimServerProcess->getProductName()); | "$0 stopped.", _cimServerProcess->getProductName()); |
|
|
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \ |
|
|| defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \ |
|
|| defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS) |
|
// |
|
// close the file created at startup time to indicate that the |
|
// cimserver has terminated normally. |
|
// |
|
FileSystem::removeFile(_cimServerProcess->getPIDFileName()); |
|
#endif |
|
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |
|
|
//l10n |
|
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
|
//"Error: $0", e.getMessage()); |
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, | Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
"src.Server.cimserver.ERROR", | "src.Server.cimserver.ERROR", |
"Error: $0", e.getMessage()); | "Error: $0", e.getMessage()); |
| |
//l10n |
|
//PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); |
|
MessageLoaderParms parms("src.Server.cimserver.ERROR", | MessageLoaderParms parms("src.Server.cimserver.ERROR", |
"Error: $0", e.getMessage()); | "Error: $0", e.getMessage()); |
PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl); |
PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << |
|
PEGASUS_STD(endl); |
| |
// | // |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |