version 1.207, 2007/08/06 07:07:48
|
version 1.217, 2008/03/05 22:27:38
|
|
|
// | // |
// cimserver daemon=false | // cimserver daemon=false |
// | // |
// The daemon config property has no effect on windows operation. |
// The daemon config property has no effect on windows operation or when |
|
// privilege separation is enabled. |
// | // |
// To shutdown pegasus, use the -s option: | // To shutdown pegasus, use the -s option: |
// | // |
|
|
#include <Service/ServerRunStatus.h> | #include <Service/ServerRunStatus.h> |
| |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) | #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
|
#include <Pegasus/Common/SetFileDescriptorToEBCDICEncoding.h> |
#include <Service/ARM_zOS.h> | #include <Service/ARM_zOS.h> |
# ifdef PEGASUS_ZOS_SECURITY | # ifdef PEGASUS_ZOS_SECURITY |
// This include file will not be provided in the OpenGroup CVS for now. | // This include file will not be provided in the OpenGroup CVS for now. |
|
|
// Set Message loading to process locale | // Set Message loading to process locale |
MessageLoader::_useProcessLocale = true; | MessageLoader::_useProcessLocale = true; |
| |
|
#ifdef PEGASUS_OS_ZOS |
|
// Direct standard input to /dev/null, |
|
close(STDIN_FILENO); |
|
open("/dev/null", O_RDONLY); |
|
|
|
if ( setEBCDICEncoding(STDOUT_FILENO)==-1 || |
|
setEBCDICEncoding(STDERR_FILENO)==-1 ) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL4, |
|
"Coud not set stdout or stderr to EBCDIC encoding."); |
|
} |
|
// Need to initialize timezone information in the |
|
// initial processing thread (IPT) |
|
tzset(); |
|
#endif |
|
|
#if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES) | #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES) |
setlocale(LC_ALL, ""); | setlocale(LC_ALL, ""); |
#endif | #endif |
|
|
for (int i = 1; i < argc; ) | for (int i = 1; i < argc; ) |
{ | { |
const char* arg = argv[i]; | const char* arg = argv[i]; |
if (String::equal(arg,"--help")) |
if (strcmp(arg, "--help") == 0) |
{ | { |
PrintHelp(argv[0]); | PrintHelp(argv[0]); |
|
Executor::daemonizeExecutor(); |
exit(0); | exit(0); |
} | } |
else if (String::equal(arg,"--version")) |
else if (strcmp(arg, "--version") == 0) |
{ | { |
cout << _cimServerProcess->getCompleteVersion() << endl; | cout << _cimServerProcess->getCompleteVersion() << endl; |
|
Executor::daemonizeExecutor(); |
exit(0); | exit(0); |
} | } |
// Check for -option | // Check for -option |
|
|
strlen(option) == 1) | strlen(option) == 1) |
{ | { |
cout << _cimServerProcess->getCompleteVersion() << endl; | cout << _cimServerProcess->getCompleteVersion() << endl; |
|
Executor::daemonizeExecutor(); |
exit(0); | exit(0); |
} | } |
// | // |
|
|
(strlen(option) == 1)) | (strlen(option) == 1)) |
{ | { |
PrintHelp(argv[0]); | PrintHelp(argv[0]); |
|
Executor::daemonizeExecutor(); |
exit(0); | exit(0); |
} | } |
#if !defined(PEGASUS_USE_RELEASE_DIRS) | #if !defined(PEGASUS_USE_RELEASE_DIRS) |
|
|
"Missing argument for option -$0", | "Missing argument for option -$0", |
opt); | opt); |
cout << MessageLoader::getMessage(parms) << endl; | cout << MessageLoader::getMessage(parms) << endl; |
exit(0); |
exit(1); |
} | } |
| |
memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*)); | memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*)); |
|
|
"Duplicate shutdown option specified."); | "Duplicate shutdown option specified."); |
| |
cout << MessageLoader::getMessage(parms) << endl; | cout << MessageLoader::getMessage(parms) << endl; |
exit(0); |
exit(1); |
} | } |
| |
shutdownOption = true; | shutdownOption = true; |
|
|
daemonOption = ConfigManager::parseBooleanValue( | daemonOption = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("daemon")); | configManager->getCurrentValue("daemon")); |
| |
|
if ((Executor::detectExecutor() == 0) && (daemonOption == false)) |
|
{ |
|
MessageLoaderParms parms( |
|
"src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON", |
|
"Warning: The configuration setting daemon=false is ignored " |
|
"with privilege separation enabled."); |
|
cerr << MessageLoader::getMessage(parms) << endl; |
|
daemonOption = true; |
|
} |
|
|
#if !defined(PEGASUS_USE_SYSLOGS) | #if !defined(PEGASUS_USE_SYSLOGS) |
String logsDirectory = ConfigManager::getHomedPath( | String logsDirectory = ConfigManager::getHomedPath( |
configManager->getCurrentValue("logdir")); | configManager->getCurrentValue("logdir")); |
|
|
configManager->getCurrentValue("shutdownTimeout"); | configManager->getCurrentValue("shutdownTimeout"); |
Uint32 timeoutValue = | Uint32 timeoutValue = |
strtol(configTimeout.getCString(), (char **)0, 10); | strtol(configTimeout.getCString(), (char **)0, 10); |
#ifdef PEGASUS_SLP_REG_TIMEOUT |
|
// To deregister Pegasus with SLP |
|
unregisterPegasusFromSLP(); |
|
#endif |
|
| |
ServerShutdownClient serverShutdownClient(&_serverRunStatus); | ServerShutdownClient serverShutdownClient(&_serverRunStatus); |
serverShutdownClient.shutdown(timeoutValue); | serverShutdownClient.shutdown(timeoutValue); |
|
|
// The run function for the dummy Thread should never be called, | // The run function for the dummy Thread should never be called, |
dummyInitialThread = new Thread(dummyThreadFunc, NULL, false); | dummyInitialThread = new Thread(dummyThreadFunc, NULL, false); |
Thread::setCurrent(dummyInitialThread); | Thread::setCurrent(dummyInitialThread); |
AcceptLanguageList default_al; |
|
try | try |
{ | { |
default_al = LanguageParser::getDefaultAcceptLanguages(); |
Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages()); |
Thread::setLanguages(new AcceptLanguageList(default_al)); |
|
} | } |
catch (InvalidAcceptLanguageHeader& e) | catch (InvalidAcceptLanguageHeader& e) |
{ | { |
|
|
} | } |
#endif | #endif |
| |
|
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; |
|
} |
|
|
// The server HTTP and HTTPS ports are determined via this algorithm: | // The server HTTP and HTTPS ports are determined via this algorithm: |
// 1) If the user explicitly specified a port, use it. | // 1) If the user explicitly specified a port, use it. |
// 2) If the user did not specify a port, get the port from the | // 2) If the user did not specify a port, get the port from the |
|
|
} | } |
} | } |
| |
#ifdef PEGASUS_ENABLE_IPV6 |
if (addIP6Acceptor) |
|
{ |
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, | _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
portNumberHttp, false); | portNumberHttp, false); |
#endif |
} |
|
if (addIP4Acceptor) |
#if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS) |
{ |
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, | _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
portNumberHttp, false); | portNumberHttp, false); |
#endif |
} |
| |
MessageLoaderParms parms( | MessageLoaderParms parms( |
"src.Server.cimserver.LISTENING_ON_HTTP_PORT", | "src.Server.cimserver.LISTENING_ON_HTTP_PORT", |
|
|
throw InvalidPropertyValue("httpsPort", httpsPort); | throw InvalidPropertyValue("httpsPort", httpsPort); |
} | } |
} | } |
|
if (addIP6Acceptor) |
#ifdef PEGASUS_ENABLE_IPV6 |
{ |
_cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, | _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION, |
portNumberHttps, true); | portNumberHttps, true); |
#endif |
} |
|
if (addIP4Acceptor) |
#if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS) |
{ |
_cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, | _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION, |
portNumberHttps, true); | portNumberHttps, true); |
#endif |
} |
|
|
MessageLoaderParms parms( | MessageLoaderParms parms( |
"src.Server.cimserver.LISTENING_ON_HTTPS_PORT", | "src.Server.cimserver.LISTENING_ON_HTTPS_PORT", |
"Listening on HTTPS port $0.", portNumberHttps); | "Listening on HTTPS port $0.", portNumberHttps); |
|
|
// 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) |
{ | { |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
|
Executor::daemonizeExecutor(); |
|
#else |
|
_cimServerProcess->notify_parent(0); | _cimServerProcess->notify_parent(0); |
#endif |
|
} | } |
| |
#if defined(PEGASUS_DEBUG) | #if defined(PEGASUS_DEBUG) |
|
|
{ | { |
// Direct standard input, output, and error to /dev/null, | // Direct standard input, output, and error to /dev/null, |
// since we are running as a daemon. | // since we are running as a daemon. |
close(0); |
close(STDIN_FILENO); |
open("/dev/null", O_RDONLY); | open("/dev/null", O_RDONLY); |
close(1); |
close(STDOUT_FILENO); |
open("/dev/null", O_RDWR); | open("/dev/null", O_RDWR); |
close(2); |
close(STDERR_FILENO); |
open("/dev/null", O_RDWR); | open("/dev/null", O_RDWR); |
} | } |
#endif | #endif |
|
|
| |
#endif | #endif |
| |
|
// In case we don't want to reregister to SLP |
|
// (i.e. PEGASUS_SLP_REG_TIMEOUT not set) after CIM Server startup, |
|
// the SLP Provider is started only once, |
|
// right short before entering the runForever loop which then can handle |
|
// the invokeMethod call against the SLP provider |
|
// function startSLPProvider() does create a separate thread to process |
|
// so code continues to go into the forever loop before executing any |
|
// requests against the CIM Server |
|
#ifdef PEGASUS_ENABLE_SLP |
|
# ifndef PEGASUS_SLP_REG_TIMEOUT |
|
_cimServer->startSLPProvider(); |
|
# endif |
|
#endif |
// | // |
// Loop to call CIMServer's runForever() method until CIMServer | // Loop to call CIMServer's runForever() method until CIMServer |
// has been shutdown | // has been shutdown |