(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.116 and 1.117

version 1.116, 2003/10/15 19:29:59 version 1.117, 2003/10/16 04:37:54
Line 40 
Line 40 
 // //
 // Modified By: Humberto Rivero (hurivero@us.ibm.com) // Modified By: Humberto Rivero (hurivero@us.ibm.com)
 // //
   // Modified By: Steve Hills (steve.hills@ncr.com)
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
  
Line 75 
Line 77 
 // To START the Pegasus service, // To START the Pegasus service,
 // //
 // net start cimserver // net start cimserver
   // or
   // cimserver -start
 // //
 // To STOP the Pegasus service, // To STOP the Pegasus service,
 // //
 // net stop cimserver // net stop cimserver
   // or
   // cimserver -stop
 // //
 // Alternatively, you can use the windows service manager. Pegasus shows up // Alternatively, you can use the windows service manager. Pegasus shows up
 // in the service database as "Pegasus CIM Object Manager" // in the service database as "Pegasus CIM Object Manager"
Line 106 
Line 112 
 #include <Pegasus/Server/ShutdownService.h> #include <Pegasus/Server/ShutdownService.h>
 #include <Pegasus/Common/Destroyer.h> #include <Pegasus/Common/Destroyer.h>
  
   int cimserver_run( int argc, char** argv, Pegasus::Boolean shutdownOption );
  
 #if defined(PEGASUS_OS_TYPE_WINDOWS) #if defined(PEGASUS_OS_TYPE_WINDOWS)
 # include "cimserver_windows.cpp" # include "cimserver_windows.cpp"
Line 144 
Line 151 
  
 static const char OPTION_SHUTDOWN    = 's'; static const char OPTION_SHUTDOWN    = 's';
  
 static const char OPTION_INSTALL[]   = "install";  
   
 static const char OPTION_REMOVE[]   = "remove";  
   
 static const char OPTION_START[]   = "start";  
   
 static const char OPTION_STOP[]   = "stop";  
   
 #if defined(PEGASUS_OS_HPUX) #if defined(PEGASUS_OS_HPUX)
 static const char OPTION_BINDVERBOSE = 'X'; static const char OPTION_BINDVERBOSE = 'X';
 #endif #endif
Line 160 
Line 159 
  
 ConfigManager*    configManager; ConfigManager*    configManager;
  
   /** Helper for platform specific handling. So platform specific code
       can use our single instance of CIMServer.
   */
   class CimserverHolder
   {
   public:
           CimserverHolder( CIMServer* s )
           {
                   cimserver_set( s );
           }
           virtual ~CimserverHolder()
           {
                   cimserver_set( 0 );
           }
   };
   
 /** GetOptions function - This function defines the Options Table /** GetOptions function - This function defines the Options Table
     and sets up the options from that table using the config manager.     and sets up the options from that table using the config manager.
 */ */
 void GetOptions( void GetOptions(
     ConfigManager* cm,     ConfigManager* cm,
     int& argc,     int& argc,
     char** argv,      char** argv)
     const String& pegasusHome)  
 { {
     try     try
     {     {
Line 307 
Line 321 
    return((PEGASUS_THREAD_RETURN)0);    return((PEGASUS_THREAD_RETURN)0);
 } }
  
 //  
 // cimserver_exit: platform specific exit routine calls  
 //  
 void cimserver_exit( int rc ){  
 #ifdef PEGASUS_OS_OS400  
     cimserver_exitRC(rc);  
 #endif  
     exit(rc);  
 }  
   
 void shutdownCIMOM(Uint32 timeoutValue) void shutdownCIMOM(Uint32 timeoutValue)
 { {
     //     //
Line 341 
Line 345 
         //         //
         client.setTimeout(2000);         client.setTimeout(2000);
     }     }
     catch(Exception& e)      catch(Exception&)
     {     {
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
         //l10n         //l10n
Line 353 
Line 357 
         // 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.
         if(cimserver_kill() == -1)         if(cimserver_kill() == -1)
            cimserver_exit(2);             cimserver_exitRC(2);
         cimserver_exit(1);          cimserver_exitRC(1);
 #else #else
         //l10n         //l10n
         //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);         //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);
Line 362 
Line 366 
         MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",         MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
                                                          "Unable to connect to CIM Server.\nCIM Server may not be running.\n");                                                          "Unable to connect to CIM Server.\nCIM Server may not be running.\n");
         PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);         PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
           exit(1);
 #endif #endif
         cimserver_exit(1);  
     }     }
  
     try     try
Line 423 
Line 427 
         }         }
         // Kill the server job.         // Kill the server job.
         if(cimserver_kill() == -1)         if(cimserver_kill() == -1)
            cimserver_exit(2);             cimserver_exitRC(2);
 #else #else
         //l10n - TODO         //l10n - TODO
         MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",         MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",
Line 462 
Line 466 
                                      "Forced shutdown initiated.");                                      "Forced shutdown initiated.");
             PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);             PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
         }         }
           exit(1);
 #endif #endif
         cimserver_exit(1);  
   
     }     }
     catch(Exception& e)      catch(Exception&)
     {     {
         //         //
         // This may mean that the CIM Server has terminated, causing this         // This may mean that the CIM Server has terminated, causing this
Line 496 
Line 499 
  
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
             if(kill_rc == -1)             if(kill_rc == -1)
                 cimserver_exit(2);                  cimserver_exitRC(2);
             cimserver_exit(1);              cimserver_exitRC(1);
 #endif #endif
  
 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
Line 526 
Line 529 
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
     String pegasusHome  = String::EMPTY;     String pegasusHome  = String::EMPTY;
     String logsDirectory = String::EMPTY;  
     Boolean daemonOption = false;  
     Boolean shutdownOption = false;     Boolean shutdownOption = false;
     Uint32 timeoutValue  = 0;  
  
 //l10n //l10n
 // Set Message loading to process locale // Set Message loading to process locale
Line 577 
Line 577 
   // windows only   // windows only
   setHome(pegasusHome);   setHome(pegasusHome);
 #endif #endif
     // on Windows NT if there are no command-line options, run as a service  
  
     if (argc == 1 )  
     {  
       cim_server_service(argc, argv);  
     }  
     else  
     {  
         // Get help, version, and shutdown options         // Get help, version, and shutdown options
  
         for (int i = 1; i < argc; )         for (int i = 1; i < argc; )
Line 705 
Line 698 
                     memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));                     memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
                     argc--;                     argc--;
                 }                 }
 #ifdef PEGASUS_OS_TYPE_WINDOWS  
                 else if (strcmp(option, OPTION_INSTALL) == 0)  
                 {  
                   //  
                   // Install as a NT service  
                   //  
                   char *opt_arg = NULL;  
                   if (i+1 < argc)  
                   {  
                     opt_arg = argv[i+1];  
   
                   }  
                   if(cimserver_install_nt_service(opt_arg))  
                   {  
                      //l10n  
                       //cout << "\nPegasus installed as NT Service";  
                       MessageLoaderParms parms("src.Server.cimserver.INSTALLED_NT_SERVICE",  
                                                "\nPegasus installed as NT Service");  
   
                       cout << MessageLoader::getMessage(parms) << endl;  
                       exit(0);  
                   }  
                   else                   else
                   {                      i++;
                       exit(0);  
                   }  
                 }  
                 else if (strcmp(option, OPTION_REMOVE) == 0)  
                 {  
                   //  
                   // Remove Pegasus as an NT service  
                   //  
                   char *opt_arg = NULL;  
                   if (i+1 < argc)  
                   {  
                     opt_arg = argv[i+1];  
                   }  
                   if(cimserver_remove_nt_service(opt_arg))  
                   {  
                       //l10n  
                       //cout << "\nPegasus removed as NT Service";  
                       MessageLoaderParms parms("src.Server.cimserver.REMOVED_NT_SERVICE",  
                                                "\nPegasus removed as NT Service");  
   
                       cout << MessageLoader::getMessage(parms) << endl;  
                       exit(0);  
                   }                   }
                   else                   else
                   {                  i++;
                       exit(0);  
                   }                   }
  
                 }  
                 else if (strcmp(option, OPTION_START) == 0)  
                 {  
                   //                   //
                   // Start as a NT service      // Set the value for pegasusHome property
                   //                   //
                   char *opt_arg = NULL;      ConfigManager::setPegasusHome(pegasusHome);
                   if (i+1 < argc)  
                   {  
                     opt_arg = argv[i+1];  
                   }  
                   if(cimserver_start_nt_service(opt_arg))  
                   {  
                       //l10n  
                       //cout << "\nPegasus started as NT Service";  
                       MessageLoaderParms parms("src.Server.cimserver.STARTED_NT_SERVICE",  
                                                "\nPegasus started as NT Service");  
  
                       cout << MessageLoader::getMessage(parms) << endl;  
                       exit(0);  
                   }  
                   else  
                   {  
                       exit(0);  
                   }  
                 }  
                 else if (strcmp(option, OPTION_STOP) == 0)  
                 {  
                   //                   //
                   // Stop as a NT service      // Do the plaform specific run
                   //                   //
                   char *opt_arg = NULL;  
                   if (i+1 < argc)  
                   {  
                     opt_arg = argv[i+1];  
                   }  
                   if(cimserver_stop_nt_service(opt_arg))  
                   {  
                       //l10n  
                       //cout << "\nPegasus stopped as NT Service";  
                       MessageLoaderParms parms("src.Server.cimserver.STOPPED_NT_SERVICE",  
                                                "\nPegasus stopped as NT Service");  
  
                       cout << MessageLoader::getMessage(parms) << endl;      return platform_run( argc, argv, shutdownOption );
                       exit(0);  
                   }  
                   else  
                   {  
                       exit(0);  
                   }  
                 }  
 #endif  
                 else  
                     i++;  
             }  
             else  
                 i++;  
         }  
     }     }
  
   
     //     //
     // Set the value for pegasusHome property  // The main, common, running code
     //     //
     ConfigManager::setPegasusHome(pegasusHome);  // 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 cimserver_run( int argc, char** argv, Boolean shutdownOption )
   {
       String logsDirectory = String::EMPTY;
       Boolean daemonOption = false;
  
     //     //
     // Get an instance of the Config Manager.     // Get an instance of the Config Manager.
Line 834 
Line 748 
     //     //
     try     try
     {     {
         GetOptions(configManager, argc, argv, pegasusHome);          GetOptions(configManager, argc, argv);
     }     }
     catch (Exception& e)     catch (Exception& e)
     {     {
Line 844 
Line 758 
 #else #else
         cerr << argv[0] << ": " << e.getMessage() << endl;         cerr << argv[0] << ": " << e.getMessage() << endl;
 #endif #endif
         exit(1);          return(1);
     }     }
  
 // l10n // l10n
Line 880 
Line 794 
         MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",         MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
                                                          "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");                                                          "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");
         cerr << MessageLoader::getMessage(parms) << endl;         cerr << MessageLoader::getMessage(parms) << endl;
         exit(1);          return(1);
     }     }
 #endif #endif
  
Line 920 
Line 834 
         {         {
             String configTimeout =             String configTimeout =
                 configManager->getCurrentValue("shutdownTimeout");                 configManager->getCurrentValue("shutdownTimeout");
             timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);              Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
  
             shutdownCIMOM(timeoutValue);             shutdownCIMOM(timeoutValue);
  
Line 931 
Line 845 
                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
                         "src.Server.cimserver.SERVER_STOPPED",                         "src.Server.cimserver.SERVER_STOPPED",
                         "CIM Server stopped.");                         "CIM Server stopped.");
               cimserver_exitRC(0);
 #else #else
                         //l10n                         //l10n
             //cout << "CIM Server stopped." << endl;             //cout << "CIM Server stopped." << endl;
Line 938 
Line 853 
                                                          "CIM Server stopped.");                                                          "CIM Server stopped.");
  
             cout << MessageLoader::getMessage(parms) << endl;             cout << MessageLoader::getMessage(parms) << endl;
               return(0);
 #endif #endif
             cimserver_exit(0);  
         }         }
  
         // Leave this in until people get familiar with the logs.         // Leave this in until people get familiar with the logs.
Line 1029 
Line 944 
         if(-1 == cimserver_fork())         if(-1 == cimserver_fork())
 #ifndef PEGASUS_OS_OS400 #ifndef PEGASUS_OS_OS400
         {         {
             exit(-1);              return(-1);
         }         }
 #else #else
         {         {
Line 1078 
Line 993 
         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
                                   "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",                                   "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",
                           "CIM Server failed to initialize");                           "CIM Server failed to initialize");
         exit(-1);          return(-1);
     }     }
 #endif #endif
  
Line 1106 
Line 1021 
         if (daemonOption)         if (daemonOption)
                 notify_parent(1);                 notify_parent(1);
  
         exit(1);          return(1);
     }     }
  
 #endif #endif
Line 1128 
Line 1043 
         CIMServer server(&monitor);         CIMServer server(&monitor);
 #endif #endif
  
           CimserverHolder cimserverHolder( &server );
  
         if (enableHttpConnection)         if (enableHttpConnection)
         {         {


Legend:
Removed from v.1.116  
changed lines
  Added in v.1.117

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2