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

📄 cimlistener.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	*strrchr(exeDir, '\\') = '\0';	pegasusHome = String(exeDir);#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 << _cimListenerProcess->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 << _cimListenerProcess->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                //                // Check to see if user asked for debug output (-X option):                //                else if (*option == OPTION_DEBUGOUTPUT &&                        (strlen(option) == 1))                {                    MessageLoaderParms parms(                        "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",                        "Unsupported debug output option is enabled.");                    cout << MessageLoader::getMessage(parms) << endl;                    debugOutputOption = true;#if defined(PEGASUS_OS_HPUX)                    System::bindVerbose = true;#endif                    // remove the option from the command line                    memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));                    argc--;                }                //                // 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("DynListener.cimlistener.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    //    DynamicListenerConfig::setListenerHome(pegasusHome);    //    // Do the plaform specific run    //    return _cimListenerProcess->platform_run(        argc, argv, shutdownOption, debugOutputOption);}void CIMListenerProcess::cimserver_stop(){    _cimListener->stop();}//// 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 CIMListenerProcess::cimserver_run(    int argc,    char** argv,    Boolean shutdownOption,    Boolean debugOutputOption){    String logsDirectory = String::EMPTY;	String homeDir = configManager->getListenerHome();    //    // Get an instance of the Config Manager.    //    //configManager = DynamicListenerConfig::getInstance();    //    // Check to see if we should Pegasus as a daemon    //    Boolean daemonOption;#if defined(PEGASUS_OS_TYPE_WINDOWS)    daemonOption = false;#else    daemonOption = true;    for (int i=1; i < argc; i++)    {        if (strcmp(argv[i], OPTION_NO_DAEMON) == 0)        {            daemonOption = false;            break;        }    }#endif#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 = daemonOption ? true : false;#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		String configFilePath = homeDir + "/" + DEFAULT_CONFIG_FILE;		FileSystem::translateSlashes(configFilePath);        configManager->initOptions(configFilePath);    }    catch (Exception& e)    {        Logger::put_l(Logger::ERROR_LOG, System::CIMLISTENER, Logger::SEVERE,            "src.Server.cimserver.SERVER_NOT_STARTED",            "cimserver not started:  $0", e.getMessage());#if !defined(PEGASUS_OS_OS400)        MessageLoaderParms parms("DynListener.cimlistener.LISTENER_NOT_STARTED",                                 "CIM Listener 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.	String msgHome = homeDir + "/msg";	FileSystem::translateSlashes(msgHome);	MessageLoader::setPegasusMsgHome(msgHome);    //    // Check to see if we need to shutdown CIMOM    //    if (shutdownOption)    {        //gracefully exit        //Uncomment the following line when signals are implemented on all platforms.        //The workaround is to use a file.#ifdef PEGASUS_HAS_SIGNALS        FILE *pid_file;        pid_t pid = 0;        // open the file containing the CIMServer process ID        pid_file = fopen(getPIDFileName(), "r");        if (!pid_file)         {            return (-1);        }        // get the pid from the file        fscanf(pid_file, "%d\n", &pid);        fclose(pid_file);        if (pid == 0)        {           System::removeFile(getPIDFileName());           return (-1);        }        int rc = kill(pid, PEGASUS_SIGTERM);        // check for success or failure of the kill operation        if (rc == -1)        {            if (errno == EPERM)            {                MessageLoaderParms parms(                    "DynListener.cimlistener.KILL_PERM_DENIED",                    "Permission denied: Not permitted to shutdown cimlistener process.");                cout << MessageLoader::getMessage(parms) << endl;            } else            {                MessageLoaderParms parms(                    "DynListener.cimlistener.KILL_FAILED",                    "Failed to shutdown cimlistener process. Error: \"$1\"",                    strerror(errno));                cout << MessageLoader::getMessage(parms) << endl;            }            return(rc);        }        //cimserver_kill(1);#else#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)        // Check to see if the CIM Listener is running. No need to stop if not running.        if(_cimListenerProcess->isCIMServerRunning())        {            // remove the old file if it exists            System::removeFile(LISTENER_STOP_FILE);            // open the file            FILE *pid_file = fopen(LISTENER_STOP_FILE, "w");            if (pid_file)            {                // save the pid in the file                fprintf(pid_file, "%ld\n", _cimListenerProcess->get_server_pid());                fclose(pid_file);            }        } else {            printf("CIM Listener may not be running.\n");            return(0);        }#endif#endif //PEGASUS_HAS_SIGNALS#ifdef PEGASUS_OS_OS400    //l10n    //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,        //"CIM Server stopped.");    Logger::put_l(Logger::ERROR_LOG, System::CIMLISTENER, Logger::INFORMATION,        "src.Server.cimserver.SERVER_STOPPED",        "CIM Server stopped.");        cimserver_exitRC(0);#else        //l10n        //cout << "CIM Server stopped." << endl;        MessageLoaderParms parms("DynListener.cimlistener.LISTENER_STOPPED",                                 "CIM Listener stopped.");        cout << MessageLoader::getMessage(parms) << endl;        return(0);#endif    }	//get config options.  note that the paths will be converted to homedPaths in the lookup calls.    Uint32 listenerPort;    Boolean httpsConnection;    String sslKeyFilePath;    String sslCertificateFilePath;    String consumerDir;    String consumerConfigDir;    Boolean enableConsumerUnload;    Uint32 consumerIdleTimeout;    Uint32 shutdownTimeout;    String traceFile;    Uint32 traceLevel;    String traceComponents;#ifdef PEGASUS_OS_OS400    if (os400StartupOption)    {        //set fixed values for OS400        listenerPort = 5999;        httpsConnection = false;        sslKeyFilePath = "";        sslCertificateFilePath = "";        consumerDir = "";        consumerConfigDir = "";        enableConsumerUnload = false;        consumerIdleTimeout = 0;        shutdownTimeout = 10;        traceFile = "cimlistener.trc";        traceLevel = 0;        traceComponents = "LISTENER";    } else    {#endif	try    {    configManager->lookupIntegerValue("listenerPort", listenerPort);    httpsConnection = configManager->isTrue("enableHttpsListenerConnection");

⌨️ 快捷键说明

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