version 1.54, 2002/05/28 18:47:11
|
version 1.57, 2002/06/01 00:25:05
|
|
|
// CIM Server gets shutdown, if CIM Server is still running at | // CIM Server gets shutdown, if CIM Server is still running at |
// this time, we will kill the cimserver process. | // this time, we will kill the cimserver process. |
// | // |
|
// give CIM Server some time to finish up |
#if defined(PEGASUS_OS_HPUX) |
// |
|
|
// give cimom some time to finish up |
|
System::sleep(1); | System::sleep(1); |
|
cimserver_kill(); |
// add code to kill cimom if it is still running |
|
|
|
#endif |
|
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |
PEGASUS_STD(cerr) << "Failed to shutdown server: "; |
PEGASUS_STD(cerr) << "Error occurred while stopping the CIM Server: "; |
PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl); |
exit(1); | exit(1); |
} | } |
|
|
// | // |
// check to see if user is root | // check to see if user is root |
// | // |
if (!System::isPrivilegedUser()) |
if (!System::isPrivilegedUser(System::getEffectiveUserName())) |
{ | { |
cout << "You must have superuser privilege to run "; | cout << "You must have superuser privilege to run "; |
cout << "cimserver." << endl; | cout << "cimserver." << endl; |
|
|
// 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 |
Logger::setHomeDirectory(logsDirectory); | Logger::setHomeDirectory(logsDirectory); |
|
#endif |
| |
// | // |
// Check to see if we need to shutdown CIMOM | // Check to see if we need to shutdown CIMOM |
|
|
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 |
cout << "Logs Directory = " << logsDirectory << endl; | cout << "Logs Directory = " << logsDirectory << endl; |
|
#endif |
| |
if (String::equal(configManager->getCurrentValue("cleanlogs"), "true")) | if (String::equal(configManager->getCurrentValue("cleanlogs"), "true")) |
{ | { |
|
|
exit(-1); | exit(-1); |
} | } |
| |
// Put server starting message to the logger |
|
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
|
"Starting $0 version $1 on port $2 $3 $4 $5", |
|
PEGASUS_NAME, |
|
PEGASUS_VERSION, |
|
address, |
|
(useSLP ? " SLP on " : " SLP off "), |
|
(useSSL ? " Use SSL " : " No SSL ")); |
|
|
|
// 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_HPUX) | #if defined(PEGASUS_OS_HPUX) |
// | // |
// create a file to indicate that the cimserver has started |
// create a file to indicate that the cimserver has started and |
// |
// save the process id of the cimserver process in the file |
fstream fs; |
|
ArrayDestroyer<char> p(CIMSERVERSTART_FILE.allocateCString()); |
|
fs.open(p.getPointer(), ios::in | ios::out); |
|
if (!fs) |
|
{ |
|
// | // |
// failed to create the file, write an entry to the log file |
|
// and proceed |
// remove the old file if it exists |
// |
System::removeFile(fname); |
//Logger::put(Logger::STANDARD_LOG, "CIMServer", |
|
// Logger::INFORMATION, |
// open the file |
// "Failed to open the $0 file needed by cimserverd.", |
FILE *pid_file = fopen(fname, "w"); |
// CIMSERVERSTART_FILE); |
if (pid_file) |
} |
|
else |
|
{ | { |
fs.close(); |
// save the pid in the file |
|
fprintf(pid_file, "%ld\n", (long)server_pid); |
|
fclose(pid_file); |
} | } |
#endif | #endif |
cout << "Started. " << endl; | cout << "Started. " << endl; |
| |
// Put server started message to the logger | // Put server started message to the logger |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"$0 started.", PEGASUS_NAME); |
"Started $0 version $1 on port $2.", |
|
PEGASUS_NAME, PEGASUS_VERSION, address); |
|
|
| |
// | // |
// Loop to call CIMServer's runForever() method until CIMServer | // Loop to call CIMServer's runForever() method until CIMServer |
|
|
| |
#if defined(PEGASUS_OS_HPUX) | #if defined(PEGASUS_OS_HPUX) |
// | // |
// close the file at startup time to indicate that the cimserver |
// close the file created at startup time to indicate that the |
// has terminated normally. |
// cimserver has terminated normally. |
// | // |
FileSystem::removeFile(CIMSERVERSTART_FILE); | FileSystem::removeFile(CIMSERVERSTART_FILE); |
#endif | #endif |
|
|
catch(Exception& e) | catch(Exception& e) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"$0 Abnormal Termination.", e.getMessage()); |
"$0 .Abnormal Termination.", e.getMessage()); |
| |
PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); |
return 1; | return 1; |