version 1.191, 2006/11/29 22:09:32
|
version 1.196, 2007/04/03 18:51:01
|
|
|
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&) |
{ | { |
|
|
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// |
int main(int argc, char** argv) | int main(int argc, char** argv) |
{ | { |
String pegasusHome = String::EMPTY; |
String pegasusHome; |
Boolean shutdownOption = false; | Boolean shutdownOption = false; |
Boolean debugOutputOption = false; | Boolean debugOutputOption = false; |
| |
|
|
Boolean shutdownOption, | Boolean shutdownOption, |
Boolean debugOutputOption) | Boolean debugOutputOption) |
{ | { |
String logsDirectory = String::EMPTY; |
String logsDirectory; |
Boolean daemonOption = false; | Boolean daemonOption = false; |
| |
// | // |
|
|
#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 |
|
|
# 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 |
// | // |