(file) Return to cimserver.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Server

Diff for /pegasus/src/Server/cimserver.cpp between version 1.66 and 1.81

version 1.66, 2002/08/23 16:11:21 version 1.81, 2002/10/30 20:33:00
Line 32 
Line 32 
 // Modified By: Jenny Yu (jenny_yu@hp.com) // Modified By: Jenny Yu (jenny_yu@hp.com)
 // //
 // Modified By: Sushma Fernandes (sushma_fernandes@hp.com) // Modified By: Sushma Fernandes (sushma_fernandes@hp.com)
   //              Carol Ann Krug Graves, Hewlett-Packard Company
   //                (carolann_graves@hp.com)
   //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 83 
Line 86 
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/suballoc/suballoc.h>  
 #include <iostream> #include <iostream>
 #include <cassert> #include <cassert>
 #include <cstdlib> #include <cstdlib>
Line 99 
Line 101 
 #include <Pegasus/Client/CIMClient.h> #include <Pegasus/Client/CIMClient.h>
 #include <Pegasus/Server/ShutdownService.h> #include <Pegasus/Server/ShutdownService.h>
 #include <Pegasus/Common/Destroyer.h> #include <Pegasus/Common/Destroyer.h>
 #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX)  #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP)
 #include <slp/slp.h> #include <slp/slp.h>
 #endif #endif
  
Line 206 
Line 208 
     usage.append ("    -v          - displays CIM Server version number\n");     usage.append ("    -v          - displays CIM Server version number\n");
     usage.append ("    -h          - prints this help message\n");     usage.append ("    -h          - prints this help message\n");
     usage.append ("    -s          - shuts down CIM Server\n");     usage.append ("    -s          - shuts down CIM Server\n");
 #ifndef PEGASUS_OS_HPUX  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
     usage.append ("    -D [home]   - sets pegasus home directory\n");     usage.append ("    -D [home]   - sets pegasus home directory\n");
 #endif #endif
 #if defined(PEGASUS_OS_TYPE_WINDOWS) #if defined(PEGASUS_OS_TYPE_WINDOWS)
Line 217 
Line 219 
     usage.append ("                - sets CIM Server configuration property\n");     usage.append ("                - sets CIM Server configuration property\n");
  
     cout << endl;     cout << endl;
 #if defined(PEGASUS_OS_HPUX)  #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
     cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl;     cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl;
 #else #else
     cout << PEGASUS_NAME << PEGASUS_VERSION << endl;     cout << PEGASUS_NAME << PEGASUS_VERSION << endl;
Line 248 
Line 250 
         //         //
         // set client timeout to 2 seconds         // set client timeout to 2 seconds
         //         //
         client.setTimeOut(2000);          client.setTimeout(2000);
     }     }
     catch(Exception& e)     catch(Exception& e)
     {     {
Line 258 
Line 260 
         // The server job may still be active but not responding.         // The server job may still be active but not responding.
         // Kill the job if it exists.         // Kill the job if it exists.
         cimserver_kill();         cimserver_kill();
           return;
 #endif #endif
         exit(0);         exit(0);
     }     }
Line 269 
Line 272 
         //         //
         String referenceStr = "//";         String referenceStr = "//";
         referenceStr.append(hostStr);         referenceStr.append(hostStr);
         referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN);          referenceStr.append("/");
           referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString());
         referenceStr.append(":");         referenceStr.append(":");
         referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN);          referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString());
         CIMObjectPath reference(referenceStr);         CIMObjectPath reference(referenceStr);
  
         //         //
Line 309 
Line 313 
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
         // Kill the server job.         // Kill the server job.
         cimserver_kill();         cimserver_kill();
           return;
 #endif #endif
         exit(1);         exit(1);
     }     }
Line 416 
Line 421 
                 //                 //
                 if (*option == OPTION_VERSION)                 if (*option == OPTION_VERSION)
                 {                 {
 #if defined(PEGASUS_OS_HPUX)  #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
                     cout << PLATFORM_PRODUCT_VERSION << endl;                     cout << PLATFORM_PRODUCT_VERSION << endl;
 #else #else
                     cout << PEGASUS_VERSION << endl;                     cout << PEGASUS_VERSION << endl;
Line 431 
Line 436 
                     PrintHelp(argv[0]);                     PrintHelp(argv[0]);
                     exit(0);                     exit(0);
                 }                 }
 #ifndef PEGASUS_OS_HPUX  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
                 else if (*option == OPTION_HOME)                 else if (*option == OPTION_HOME)
                 {                 {
                     if (i + 1 < argc)                     if (i + 1 < argc)
Line 470 
Line 475 
                     //                     //
                     // check to see if user is root                     // check to see if user is root
                     //                     //
   #ifndef PEGASUS_OS_OS400
                     if (!System::isPrivilegedUser(System::getEffectiveUserName()))                     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;
                         exit(0);                         exit(0);
                     }                     }
   #endif
  
                     //                     //
                     // Check to see if shutdown has already been specified:                     // Check to see if shutdown has already been specified:
Line 584 
Line 591 
         // 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  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
         Logger::setHomeDirectory(logsDirectory);         Logger::setHomeDirectory(logsDirectory);
 #endif #endif
  
Line 595 
Line 602 
         {         {
             String configTimeout =             String configTimeout =
                 configManager->getCurrentValue("shutdownTimeout");                 configManager->getCurrentValue("shutdownTimeout");
             ArrayDestroyer<char> timeoutCString(configTimeout.allocateCString());              timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
             timeoutValue = strtol(timeoutCString.getPointer(), (char **)0, 10);  
  
             shutdownCIMOM(timeoutValue);             shutdownCIMOM(timeoutValue);
  
             cout << "CIM Server stopped." << endl;             cout << "CIM Server stopped." << endl;
   #ifdef PEGASUS_OS_OS400
               return(0);
   #endif
             exit(0);             exit(0);
         }         }
  
Line 613 
Line 622 
         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  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
         cout << "Logs Directory = " << logsDirectory << endl;         cout << "Logs Directory = " << logsDirectory << endl;
 #endif #endif
  
Line 627 
Line 636 
             useSLP =  true;             useSLP =  true;
         }         }
  
   #if defined(PEGASUS_USE_RELEASE_CONFIG_OPTIONS)
           Boolean enableHttpConnection = String::equal(
               configManager->getCurrentValue("enableHttpConnection"), "true");
           Boolean enableHttpsConnection = String::equal(
               configManager->getCurrentValue("enableHttpsConnection"), "true");
   
           if (enableHttpConnection && enableHttpsConnection)
           {
               Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
                   "Enabling both HTTP and HTTPS connections is unsupported.  "
                   "Only the HTTPS connection is enabled.");
               cerr << "Enabling both HTTP and HTTPS connections is unsupported.  "
                   "Only the HTTPS connection is enabled." << endl;
           }
           else if (!enableHttpConnection && !enableHttpsConnection)
           {
               Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
                   "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;
               exit(1);
           }
   
           useSSL = enableHttpsConnection;
   
   #else
         if (String::equal(configManager->getCurrentValue("SSL"), "true"))         if (String::equal(configManager->getCurrentValue("SSL"), "true"))
         {         {
             useSSL =  true;             useSSL =  true;
         }         }
   #endif
     }     }
     catch (UnrecognizedConfigProperty e)     catch (UnrecognizedConfigProperty e)
     {     {
Line 643 
Line 680 
  
     if (useSSL)     if (useSSL)
     {     {
         char* p = httpsPort.allocateCString();  
         char* end = 0;         char* end = 0;
         Uint32 port = strtol(p, &end, 10);          CString portString = httpsPort.getCString();
           Uint32 port = strtol(portString, &end, 10);
         assert(end != 0 && *end == '\0');         assert(end != 0 && *end == '\0');
         delete [] p;  
  
         //         //
         // Look up the WBEM-HTTPS port number         // Look up the WBEM-HTTPS port number
Line 657 
Line 693 
     }     }
     else     else
     {     {
         char* p = httpPort.allocateCString();  
         char* end = 0;         char* end = 0;
         Uint32 port = strtol(p, &end, 10);          CString portString = httpPort.getCString();
           Uint32 port = strtol(portString, &end, 10);
         assert(end != 0 && *end == '\0');         assert(end != 0 && *end == '\0');
         delete [] p;  
  
         //         //
         // Look up the WBEM-HTTP port number         // Look up the WBEM-HTTP port number
Line 671 
Line 706 
     }     }
  
     // Put out startup up message.     // Put out startup up message.
 #ifndef PEGASUS_OS_HPUX  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
     cout << PEGASUS_NAME << PEGASUS_VERSION <<     cout << PEGASUS_NAME << PEGASUS_VERSION <<
          " on port " << address << endl;          " on port " << address << endl;
     cout << "Built " << __DATE__ << " " << __TIME__ << endl;     cout << "Built " << __DATE__ << " " << __TIME__ << endl;
Line 686 
Line 721 
     if (daemonOption)     if (daemonOption)
     {     {
         if(-1 == cimserver_fork())         if(-1 == cimserver_fork())
   #ifndef PEGASUS_OS_OS400
           exit(-1);           exit(-1);
   #else
             return(-1);
           else
             return(0);
   #endif
     }     }
  
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
Line 700 
Line 741 
  
 #ifdef PEGASUS_OS_HPUX #ifdef PEGASUS_OS_HPUX
     umask(S_IWGRP|S_IWOTH);     umask(S_IWGRP|S_IWOTH);
   
       //
       // check if CIMServer is already running
       // if CIMServer is already running, print message and
       // notify parent process (if there is a parent process) to terminate
       //
       if(isCIMServerRunning())
       {
           cout << "Unable to start CIMServer." << endl;
           cout << "CIMServer is already running." << endl;
   
           //
           // notify parent process (if there is a parent process) to terminate
           //
           if (daemonOption)
                   notify_parent();
   
           exit(1);
       }
   
 #endif #endif
  
     // 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_ZOS) && ! defined(PEGASUS_OS_HPUX)  #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP)
         slp_client *discovery = new slp_client() ;;         slp_client *discovery = new slp_client() ;;
         String serviceURL;         String serviceURL;
         serviceURL.assign("service:cim.pegasus://");         serviceURL.assign("service:cim.pegasus://");
         String host_name = slp_get_host_name();         String host_name = slp_get_host_name();
         serviceURL += host_name;          serviceURL.append(host_name);
         serviceURL += ":";          serviceURL.append(":");
         serviceURL += address;          serviceURL.append(address);
         char *url = serviceURL.allocateCString();  
         //      free(host_name);  
 #endif #endif
  
         Monitor monitor(true);         Monitor monitor(true);
Line 723 
Line 782 
         // bind throws an exception if the bind fails         // bind throws an exception if the bind fails
 #ifdef PEGASUS_LOCAL_DOMAIN_SOCKET #ifdef PEGASUS_LOCAL_DOMAIN_SOCKET
         cout << "Binding to domain socket" << endl;         cout << "Binding to domain socket" << endl;
 #elif !defined(PEGASUS_OS_HPUX)  #elif !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
         cout << "Binding to " << address << endl;         cout << "Binding to " << address << endl;
 #endif #endif
  
         server.bind(portNumber);         server.bind(portNumber);
  
           // notify parent process (if there is a parent process) to terminate
           // so user knows that cimserver is ready to serve CIM requests.
           if (daemonOption)
                   notify_parent();
   
         time_t last = 0;         time_t last = 0;
  
 #if defined(PEGASUS_OS_HPUX) #if defined(PEGASUS_OS_HPUX)
Line 749 
Line 813 
             fclose(pid_file);             fclose(pid_file);
         }         }
 #endif #endif
 #ifndef PEGASUS_OS_HPUX  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
         cout << "Started. " << endl;         cout << "Started. " << endl;
 #endif #endif
  
         // Put server started message to the logger         // Put server started message to the logger
 #ifdef PEGASUS_OS_HPUX  #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
         Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,         Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION,
                     "Started $0 version $1 on port $2.",                     "Started $0 version $1 on port $2.",
                     PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION, address);                     PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION, address);
Line 771 
Line 835 
         //         //
         while( !server.terminated() )         while( !server.terminated() )
         {         {
 #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX)  #if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP)
           if(useSLP  )           if(useSLP  )
           {           {
             if(  (time(NULL) - last ) > 60 )             if(  (time(NULL) - last ) > 60 )
             {             {
               if( discovery != NULL && url != NULL )                if( discovery != NULL && serviceURL.size() )
                 discovery->srv_reg_all(url,                  discovery->srv_reg_all(serviceURL.getCString(),
                                        "(namespace=root/cimv2)",                                        "(namespace=root/cimv2)",
                                        "service:cim.pegasus",                                        "service:cim.pegasus",
                                        "DEFAULT",                                        "DEFAULT",
Line 809 
Line 873 
     catch(Exception& e)     catch(Exception& e)
     {     {
         PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);         PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
   
           //
           // notify parent process (if there is a parent process) to terminate
           //
           if (daemonOption)
                   notify_parent();
   
         return 1;         return 1;
     }     }
  


Legend:
Removed from v.1.66  
changed lines
  Added in v.1.81

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2