⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimserver.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            // Repository may be empty.              //            //l10n - TODO            Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",                "Error in server shutdown: The repository may be empty.");            MessageLoaderParms parms("src.Server.cimserver.REPOSITORY_EMPTY",                                     "The repository may be empty.");            PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);        }        else        {            //l10n - TODO            Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                "src.Server.cimserver.SHUTDOWN_FAILED",                "Error in server shutdown: $0", e.getMessage());            PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl);        }    // Kill the cimserver process     if (_cimServerProcess->cimserver_kill(0) == 0)        {            //l10n - TODO            Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                "src.Server.cimserver.SERVER_FORCED_SHUTDOWN",            "Forced shutdown initiated.");            MessageLoaderParms parms("src.Server.cimserver.SERVER_FORCED_SHUTDOWN",                                     "Forced shutdown initiated.");            PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);        }        exit(1);#endif    }    catch(Exception&)    {        //        // This may mean that the CIM Server has terminated, causing this        // client to get a "Empty HTTP response message" exception.  It may        // also mean that the CIM Server is taking longer than 2 seconds         // (client timeout value) to terminate, causing this client to         // timeout with a "connection timeout" exception.        //        // Check to see if CIM Server is still running.  If CIM Server        // is still running and the shutdown timeout has not expired,        // loop and wait one second until either the CIM Server is        // terminated or timeout expires.  If timeout expires and        // the CIM Server is still running, kill the CIMServer process.        //         Uint32 maxWaitTime = 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        }    }    return;}///////////////////////////////////////////////////////////////////////////  MAIN//////////////////////////////////////////////////////////////////////////int main(int argc, char** argv){    String pegasusHome  = String::EMPTY;    Boolean shutdownOption = false;//l10n// Set Message loading to process localeMessageLoader::_useProcessLocale = true; //l10n//l10n#if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)setlocale(LC_ALL, "");#endif#ifdef PEGASUS_OS_OS400  VFYPTRS_INCDCL;               // VFYPTRS local variables  // verify pointers  #pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\    0,_C2_MH_ESCAPE)    for( int arg_index = 1; arg_index < argc; arg_index++ ){    VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));    }  #pragma disable_handler    // Convert the args to ASCII    for(Uint32 i = 0;i< argc;++i)    {    EtoA(argv[i]);    }    // Initialize Pegasus home to the shipped OS/400 directory.    pegasusHome = OS400_DEFAULT_PEGASUS_HOME;#endif#ifndef PEGASUS_OS_TYPE_WINDOWS    //    // Get environment variables:    //#ifdef PEGASUS_OS_OS400#pragma convert(37)    const char* tmp = getenv("PEGASUS_HOME");#pragma convert(0)    char home[256] = {0};    if (tmp && strlen(tmp) < 256)    {    strcpy(home, tmp);    EtoA(home);    pegasusHome = home;    }#else  #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)    pegasusHome = AIX_RELEASE_PEGASUS_HOME;  #elif !defined(PEGASUS_USE_RELEASE_DIRS)    const char* tmp = getenv("PEGASUS_HOME");    if (tmp)    {        pegasusHome = tmp;    }  #endif#endif    FileSystem::translateSlashes(pegasusHome);#else  // windows only  //setHome(pegasusHome);  pegasusHome = _cimServerProcess->getHome();#endif        // Get help, version, and shutdown options        for (int i = 1; i < argc; )        {            const char* arg = argv[i];            if(String::equal(arg,"--help"))            {                    PrintHelp(argv[0]);                    exit(0);            }            else if(String::equal(arg,"--version"))            {                cout << _cimServerProcess->getVersion() << endl;                exit(0);            }            // Check for -option            else if (*arg == '-')            {                // Get the option                const char* option = arg + 1;                //                // Check to see if user asked for the version (-v option):                //                if (*option == OPTION_VERSION &&                    strlen(option) == 1)                {                    cout << _cimServerProcess->getVersion() << endl;                    exit(0);                }                //                // Check to see if user asked for help (-h option):                //                else if (*option == OPTION_HELP &&                        (strlen(option) == 1))                {                    PrintHelp(argv[0]);                    exit(0);                }#if !defined(PEGASUS_USE_RELEASE_DIRS)                else if (*option == OPTION_HOME &&                        (strlen(option) == 1))                {                    if (i + 1 < argc)                    {                        pegasusHome.assign(argv[i + 1]);                    }                    else                    {                        //l10n                        //cout << "Missing argument for option -" << option << endl;                        String opt(option);                        MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",                                         "Missing argument for option -$0",                                         opt);                        cout << MessageLoader::getMessage(parms) << endl;                        exit(0);                    }                    memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));                    argc -= 2;                }#endif#if defined(PEGASUS_OS_HPUX)                //                // Check to see if user asked for the version (-X option):                //                if (*option == OPTION_BINDVERBOSE &&                        (strlen(option) == 1))                {            System::bindVerbose = true;                    //l10n                    //cout << "Unsupported debug option, BIND_VERBOSE, enabled."                          //<< endl;                    MessageLoaderParms parms("src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",                                         "Unsupported debug option, BIND_VERBOSE, enabled.");                    cout << MessageLoader::getMessage(parms) << endl;                    // remove the option from the command line                    memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));                    argc--;                   }#endif                //                // Check to see if user asked for shutdown (-s option):                //                else if (*option == OPTION_SHUTDOWN &&                        (strlen(option) == 1))                {                    //                    // Check to see if shutdown has already been specified:                    //                    if (shutdownOption)                    {                        //l10n                        //cout << "Duplicate shutdown option specified." << endl;                        MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",                                                 "Duplicate shutdown option specified.");                                               cout << MessageLoader::getMessage(parms) << endl;                        exit(0);                    }                    shutdownOption = true;                     // remove the option from the command line                    memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));                    argc--;                   }                else                    i++;            }            else                i++;        }    //    // Set the value for pegasusHome property    //    ConfigManager::setPegasusHome(pegasusHome);    //    // Do the plaform specific run    //    return _cimServerProcess->platform_run( argc, argv, shutdownOption );}void CIMServerProcess::cimserver_stop(){    _cimServer->shutdownSignal();}//// The main, common, running code//// NOTE: Do NOT call exit().  Use return(), otherwise some platforms // will fail to shutdown properly/cleanly.//// TODO: Current change minimal for platform "service" shutdown bug fixes.  // Perhpas further extract out common stuff and put into main(), put // daemon stuff into platform specific platform_run(), etc.  // Note: make sure to not put error handling stuff that platform // specific runs may need to deal with bettter (instead of exit(), etc).//int CIMServerProcess::cimserver_run( int argc, char** argv, Boolean shutdownOption ){    String logsDirectory = String::EMPTY;    Boolean daemonOption = false;    //    // Get an instance of the Config Manager.    //    configManager = ConfigManager::getInstance();    configManager->useConfigFiles = true;#ifdef PEGASUS_OS_OS400    // In a special startup case for IBM OS400, when the server is    // automatically started when the machine starts up the config    // file cannot be read because of access restrictions for the    // user starting the server.  In this case, we need to skip    // reading the config options and therefore any use of the config    // manager also.  To make this determinations we will check to see    // if the daemon flag is set to true.  If so, then there will be a    // series of checks to bracket all the calls to the configManager    // which would otherwise fail.  All this will only be done for    // IBM OS400.    Boolean os400StartupOption = false;    // loop through args to check for daemon=true    for (int i=1; i < argc; i++)      if (strcmp(argv[i], "daemon=true") == 0)      {        os400StartupOption = true;        daemonOption = true;      }#endif        //    // Get options (from command line and from configuration file); this    // removes corresponding options and their arguments from the command    // line.    //    try    {#ifdef PEGASUS_OS_OS400    if (os400StartupOption == false)#endif           GetOptions(configManager, argc, argv);    }    catch (Exception& e)    {        Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,            "src.Server.cimserver.SERVER_NOT_STARTED",            "cimserver not started:  $0", e.getMessage());#if !defined(PEGASUS_OS_OS400)        MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",            "cimserver not started: $0", e.getMessage());        PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)            << PEGASUS_STD(endl);#endif        return(1);    }// l10n    // Set the home directory, msg sub-dir, into the MessageLoader.    // This will be the default directory where the resource bundles     // are found.        MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(        ConfigManager::getInstance()->getCurrentValue("messageDir")));      #ifdef PEGASUS_OS_OS400    // Still need to declare and set the connection variables.    // Will initialize to false since they are fixed at false for OS400.    // NOTE:  OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down    // the test will not be compiled in.  If OS400 ever turns off that    // define, then we will need to change this code path to insure that    // one of the variables is true.        Boolean enableHttpConnection = false;    Boolean enableHttpsConnection = false;    if (os400StartupOption == false)    {      enableHttpConnection = ConfigManager::parseBooleanValue(          configManager->getCurrentValue("enableHttpConnection"));      enableHttpsConnection = ConfigManager::parseBooleanValue(          configManager->getCurrentValue("enableHttpsConnection"));    }#else    Boolean enableHttpConnection = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableHttpConnection"));    Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableHttpsConnection"));#endif    // Make sure at least one connection is enabled#ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET    if (!enableHttpConnection && !enableHttpsConnection)    {        //l10n        //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,            //"Neither HTTP nor HTTPS connection is enabled.  "            //"CIMServer will not be started.");        Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,            "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",            "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");        //cerr << "Neither HTTP nor HTTPS connection is enabled.  "            //"CIMServer will not be started." << endl;        MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",                                 "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");        cerr << MessageLoader::getMessage(parms) << endl;        return(1);    }#endif    try    {        //        // Check to see if we should Pegasus as a daemon        //        daemonOption = ConfigManager::parseBooleanValue(            configManager->getCurrentValue("daemon"));    #ifdef PEGASUS_OS_OS400    if (os400StartupOption == false)    {#endif                    // Get the log file directory definition.        // We put String into Cstring because        // Directory functions only handle Cstring.        // ATTN-KS: create String based directory functions.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -