version 1.191, 2006/11/29 22:09:32
|
version 1.191.4.5, 2008/01/09 05:55:53
|
|
|
// | // |
////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////// |
| |
|
//NOCHKSRC |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Constants.h> | #include <Pegasus/Common/Constants.h> |
|
|
void GetOptions( | void GetOptions( |
ConfigManager* cm, | ConfigManager* cm, |
int& argc, | int& argc, |
char** argv) |
char** argv, |
|
const Boolean& shutdownOption) |
{ | { |
try | try |
{ | { |
|
|
|
if (shutdownOption) |
|
{ |
|
cm->loadConfigFiles(); |
|
} |
|
else |
|
{ |
cm->mergeConfigFiles(); | cm->mergeConfigFiles(); |
|
} |
|
|
|
// Temporarily disable updates to the current configuration |
|
// file if shutdownOption is true |
|
cm->useConfigFiles = (shutdownOption==false); |
| |
cm->mergeCommandLine(argc, argv); | cm->mergeCommandLine(argc, argv); |
|
|
|
// Enable updates again |
|
cm->useConfigFiles = true; |
} | } |
catch (NoSuchFile&) | catch (NoSuchFile&) |
{ | { |
|
|
#ifdef PEGASUS_OS_OS400 | #ifdef PEGASUS_OS_OS400 |
if (os400StartupOption == false) | if (os400StartupOption == false) |
#endif | #endif |
GetOptions(configManager, argc, argv); |
// If current process is "cimserver -s" (shutdown option = true) the contents |
|
// of current config should not be overwriten by planned config |
|
GetOptions(configManager, argc, argv, shutdownOption); |
} | } |
catch (Exception& e) | catch (Exception& e) |
{ | { |
|
|
//cout << "Unable to start CIMServer." << endl; | //cout << "Unable to start CIMServer." << endl; |
//cout << "CIMServer is already running." << endl; | //cout << "CIMServer is already running." << endl; |
MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING", | MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING", |
"Unable to start CIMServer.\nCIMServer is already running."); |
"Unable to start CIMServer. CIMServer is already running."); |
PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl); |
|
Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION, |
|
MessageLoader::getMessage(parms)); |
| |
// | // |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
|
|
//CimserverHolder cimserverHolder( &server ); | //CimserverHolder cimserverHolder( &server ); |
_cimServer = new CIMServer(_monitor); | _cimServer = new CIMServer(_monitor); |
| |
|
Boolean addIP6Acceptor = false; |
|
Boolean addIP4Acceptor = false; |
|
|
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
addIP4Acceptor = true; |
|
#endif |
|
|
|
#ifdef PEGASUS_ENABLE_IPV6 |
|
// If IPv6 stack is disabled swicth to IPv4 stack. |
|
if (System::isIPv6StackActive()) |
|
{ |
|
addIP6Acceptor = true; |
|
} |
|
else |
|
{ |
|
MessageLoaderParms parms( |
|
"src.Server.cimserver.IPV6_STACK_NOT_ACTIVE", |
|
"IPv6 stack is not active, using IPv4 socket."); |
|
Logger::put( |
|
Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
MessageLoader::getMessage(parms)); |
|
#if defined(PEGASUS_DEBUG) |
|
cout << MessageLoader::getMessage(parms) << endl; |
|
#endif |
|
} |
|
#endif |
|
if (!addIP6Acceptor) |
|
{ |
|
addIP4Acceptor = true; |
|
} |
| |
if (enableHttpConnection) | if (enableHttpConnection) |
{ | { |
_cimServer->addAcceptor(false, portNumberHttp, false); |
if (addIP6Acceptor) |
|
{ |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
|
portNumberHttp, false); |
|
} |
|
if (addIP4Acceptor) |
|
{ |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
|
portNumberHttp, false); |
|
} |
//l10n | //l10n |
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
//"Listening on HTTP port $0.", portNumberHttp); | //"Listening on HTTP port $0.", portNumberHttp); |
|
|
} | } |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
_cimServer->addAcceptor(false, portNumberHttps, true); |
if (addIP6Acceptor) |
|
{ |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
|
portNumberHttps, true); |
|
} |
|
if (addIP4Acceptor) |
|
{ |
|
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
|
portNumberHttps, true); |
|
} |
|
|
//l10n | //l10n |
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
//"Listening on HTTPS port $0.", portNumberHttps); | //"Listening on HTTPS port $0.", portNumberHttps); |
|
|
} | } |
| |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
_cimServer->addAcceptor(true, 0, false); |
_cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false); |
//l10n | //l10n |
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
//"Listening on local connection socket."); | //"Listening on local connection socket."); |
|
|
# endif | # endif |
#endif | #endif |
| |
// bind throws an exception if the bind fails |
|
try { |
|
_cimServer->bind(); | _cimServer->bind(); |
} catch (const BindFailedException &e) |
|
{ |
|
#ifdef PEGASUS_DEBUG |
|
MessageLoaderParms parms("src.Server.cimserver.BIND_FAILED", |
|
"Could not bind: $0.", e.getMessage()); |
|
cout << MessageLoader::getMessage(parms) << endl; |
|
#endif |
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
"src.Server.cimserver.BIND.FAILED", |
|
"Could not bind: $0", e.getMessage()); |
|
|
|
deleteCIMServer(); |
|
return 1; |
|
} |
|
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
// so user knows that there is cimserver ready to serve CIM requests. | // so user knows that there is cimserver ready to serve CIM requests. |
if (daemonOption) | if (daemonOption) |
|
|
// | // |
#endif | #endif |
} | } |
catch(Exception& e) |
catch(BindFailedException& e) |
{ | { |
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
"src.Server.cimserver.SERVER_NOT_STARTED", |
|
"cimserver not started: $0", e.getMessage()); |
| |
//l10n |
#if !defined(PEGASUS_OS_OS400) |
//Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED", |
//"Error: $0", e.getMessage()); |
"cimserver not started: $0", e.getMessage()); |
|
|
|
cerr << MessageLoader::getMessage(parms) << endl; |
|
#endif |
|
|
|
// |
|
// notify parent process (if there is a parent process) to terminate |
|
// |
|
if (daemonOption) |
|
_cimServerProcess->notify_parent(1); |
|
|
|
deleteCIMServer(); |
|
return 1; |
|
} |
|
catch(Exception& e) |
|
{ |
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()); |
|
|
#ifndef PEGASUS_OS_OS400 | #ifndef PEGASUS_OS_OS400 |
//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); |
|
|
#endif | #endif |
|
|
// | // |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
// | // |