version 1.170, 2005/11/15 14:40:31
|
version 1.171, 2005/11/17 17:01:00
|
|
|
| |
////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////// |
// | // |
// Notes on deamon operation (Unix) and service operation (Win 32): |
// Notes on daemon operation (Unix) and service operation (Win 32): |
// | // |
// To run pegasus as a daemon on Unix platforms: | // To run pegasus as a daemon on Unix platforms: |
// | // |
|
|
{ | { |
delete _cimServer; | delete _cimServer; |
_cimServer = 0; | _cimServer = 0; |
|
|
|
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \ |
|
|| defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \ |
|
|| defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS) |
|
// |
|
// Remove the PID file to indicate CIMServer termination |
|
// |
|
FileSystem::removeFile(_cimServerProcess->getPIDFileName()); |
|
#endif |
} | } |
if (_monitor) | if (_monitor) |
{ | { |
|
|
return((PEGASUS_THREAD_RETURN)0); | return((PEGASUS_THREAD_RETURN)0); |
} | } |
| |
|
// |
|
// Waits until either the CIM Server has terminated, or the shutdown timeout |
|
// has expired. If the shutdown timeout has expired, and the CIM Server is |
|
// still running, kills the cimserver process. |
|
// |
|
void _waitForTerminationOrTimeout (Uint32 maxWaitTime) |
|
{ |
|
// |
|
// If the CIM Server is still running, and the shutdown timeout has not |
|
// expired, loop and wait one second until either the CIM Server has |
|
// terminated, or the shutdown timeout has expired |
|
// |
|
Boolean running = _cimServerProcess->isCIMServerRunning (); |
|
while (running && (maxWaitTime > 0)) |
|
{ |
|
System::sleep (1); |
|
running = _cimServerProcess->isCIMServerRunning (); |
|
maxWaitTime--; |
|
} |
|
|
|
// |
|
// If the shutdown timeout has expired, and the CIM Server is still |
|
// running, kill the cimserver process |
|
// |
|
if (running) |
|
{ |
|
int kill_rc = _cimServerProcess->cimserver_kill (0); |
|
|
|
#ifdef PEGASUS_OS_OS400 |
|
if (kill_rc == -1) |
|
{ |
|
_cimServerProcess->cimserver_exitRC (2); |
|
} |
|
_cimServerProcess->cimserver_exitRC (1); |
|
#endif |
|
|
|
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \ |
|
|| defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_SOLARIS) \ |
|
|| defined (PEGASUS_OS_VMS) |
|
if (kill_rc != -1) |
|
{ |
|
//l10n - TODO |
|
Logger::put_l (Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
"src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED", |
|
"Shutdown timeout expired. Forced shutdown initiated."); |
|
MessageLoaderParms parms |
|
("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED", |
|
"Shutdown timeout expired. Forced shutdown initiated."); |
|
cout << MessageLoader::getMessage(parms) << endl; |
|
exit (0); |
|
} |
|
#endif |
|
} |
|
} |
|
|
void shutdownCIMOM(Uint32 timeoutValue) | void shutdownCIMOM(Uint32 timeoutValue) |
{ | { |
// | // |
|
|
// (client timeout value) to terminate, causing this client to | // (client timeout value) to terminate, causing this client to |
// timeout with a "connection timeout" exception. | // timeout with a "connection timeout" exception. |
// | // |
// Check to see if CIM Server is still running. If CIM Server |
// Wait until either the CIM Server has terminated, or the shutdown |
// is still running and the shutdown timeout has not expired, |
// timeout has expired. If the timeout has expired and the CIM Server |
// loop and wait one second until either the CIM Server is |
// is still running, kill the cimserver process. |
// terminated or timeout expires. If timeout expires and |
|
// the CIM Server is still running, kill the CIMServer process. |
|
// | // |
Uint32 maxWaitTime = timeoutValue - 2; |
_waitForTerminationOrTimeout (timeoutValue - 2); |
Boolean running = _cimServerProcess->isCIMServerRunning(); |
|
while ( running && maxWaitTime > 0 ) |
|
{ |
|
System::sleep(1); |
|
running = _cimServerProcess->isCIMServerRunning(); |
|
maxWaitTime = maxWaitTime - 1; |
|
} |
|
|
|
if (running) |
|
{ |
|
int kill_rc = _cimServerProcess->cimserver_kill(0); |
|
|
|
#ifdef PEGASUS_OS_OS400 |
|
if(kill_rc == -1) |
|
_cimServerProcess->cimserver_exitRC(2); |
|
_cimServerProcess->cimserver_exitRC(1); |
|
#endif |
|
|
|
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \ |
|
|| defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_SOLARIS) \ |
|
|| defined (PEGASUS_OS_VMS) |
|
if (kill_rc != -1) |
|
{ |
|
//l10n - TODO |
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
"src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED", |
|
"Shutdown timeout expired. Forced shutdown initiated."); |
|
MessageLoaderParms parms("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED", |
|
"Shutdown timeout expired. Forced shutdown initiated."); |
|
cout << MessageLoader::getMessage(parms) << endl; |
|
exit(0); |
|
} |
|
#endif |
|
} |
|
} |
|
|
|
// Make sure the cimserver has time to actually shut down |
|
Uint32 maxWaitTime = timeoutValue; |
|
while ((maxWaitTime-- > 0) && _cimServerProcess->isCIMServerRunning()) |
|
{ |
|
System::sleep(1); |
|
} | } |
| |
|
// |
|
// InvokeMethod succeeded. |
|
// Wait until either the CIM Server has terminated, or the shutdown |
|
// timeout has expired. If the timeout has expired and the CIM Server |
|
// is still running, kill the cimserver process. |
|
// |
|
_waitForTerminationOrTimeout (timeoutValue); |
return; | return; |
} | } |
| |
|
|
ConfigManager::setPegasusHome(pegasusHome); | ConfigManager::setPegasusHome(pegasusHome); |
| |
// | // |
// Do the plaform specific run |
// Do the platform specific run |
// | // |
| |
return _cimServerProcess->platform_run( argc, argv, shutdownOption ); | return _cimServerProcess->platform_run( argc, argv, shutdownOption ); |
|
|
// will fail to shutdown properly/cleanly. | // will fail to shutdown properly/cleanly. |
// | // |
// TODO: Current change minimal for platform "service" shutdown bug fixes. | // TODO: Current change minimal for platform "service" shutdown bug fixes. |
// Perhpas further extract out common stuff and put into main(), put |
// Perhaps further extract out common stuff and put into main(), put |
// daemon stuff into platform specific platform_run(), etc. | // daemon stuff into platform specific platform_run(), etc. |
// Note: make sure to not put error handling stuff that platform | // Note: make sure to not put error handling stuff that platform |
// specific runs may need to deal with bettter (instead of exit(), etc). |
// specific runs may need to deal with better (instead of exit(), etc). |
// | // |
| |
int CIMServerProcess::cimserver_run( int argc, char** argv, Boolean shutdownOption ) | int CIMServerProcess::cimserver_run( int argc, char** argv, Boolean shutdownOption ) |
|
|
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) \ |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \ |
|| defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \ | || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \ |
|| defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS) | || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS) |
// | // |
// close the file created at startup time to indicate that the |
// Note: do not remove the PID file created at startup time, since |
// cimserver has terminated normally. |
// shutdown is not complete until the CIMServer destructor completes. |
// | // |
FileSystem::removeFile(_cimServerProcess->getPIDFileName()); |
|
#endif | #endif |
} | } |
catch(Exception& e) | catch(Exception& e) |