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

   1 karl  1.179 //%2006////////////////////////////////////////////////////////////////////////
   2 mike  1.32  //
   3 karl  1.141 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.121 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.141 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.149 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.179 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12             // EMC Corporation; Symantec Corporation; The Open Group.
  13 mike  1.32  //
  14             // Permission is hereby granted, free of charge, to any person obtaining a copy
  15 kumpf 1.58  // of this software and associated documentation files (the "Software"), to
  16             // deal in the Software without restriction, including without limitation the
  17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18 mike  1.32  // sell copies of the Software, and to permit persons to whom the Software is
  19             // furnished to do so, subject to the following conditions:
  20 karl  1.179 // 
  21 kumpf 1.58  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22 mike  1.32  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24 kumpf 1.58  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27 mike  1.32  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29             //
  30             //==============================================================================
  31             //
  32             //%/////////////////////////////////////////////////////////////////////////////
  33             
  34             
  35             //////////////////////////////////////////////////////////////////////
  36             //
  37 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
  38 mike            1.32  //
  39 david.dillard   1.165 // To run pegasus as a daemon on Unix platforms:
  40 mike            1.32  //
  41 kumpf           1.60  // cimserver
  42 mike            1.32  //
  43 kumpf           1.60  // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
  44                       // property to false:
  45                       //
  46                       // cimserver daemon=false
  47                       //
  48 david.dillard   1.165 // The daemon config property has no effect on windows operation.
  49 mike            1.32  //
  50 mike            1.35  // To shutdown pegasus, use the -s option:
  51 david.dillard   1.165 //
  52                       // cimserver -s
  53 mike            1.35  //
  54 mike            1.32  // To run pegasus as an NT service, there are FOUR  different possibilities:
  55                       //
  56 david.dillard   1.165 // To INSTALL the Pegasus service,
  57 mike            1.32  //
  58                       // cimserver -install
  59                       //
  60 david.dillard   1.165 // To REMOVE the Pegasus service,
  61 mike            1.32  //
  62                       // cimserver -remove
  63                       //
  64 david.dillard   1.165 // To START the Pegasus service,
  65 mike            1.32  //
  66                       // net start cimserver
  67 s.hills         1.117 // or
  68                       // cimserver -start
  69 mike            1.32  //
  70 david.dillard   1.165 // To STOP the Pegasus service,
  71 mike            1.32  //
  72                       // net stop cimserver
  73 s.hills         1.117 // or
  74                       // cimserver -stop
  75 mike            1.32  //
  76 david.dillard   1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
  77 mike            1.32  // in the service database as "Pegasus CIM Object Manager"
  78                       //
  79                       // Mike Day, mdday@us.ibm.com
  80 david.dillard   1.165 //
  81 mike            1.32  //////////////////////////////////////////////////////////////////////
  82                       
  83                       
  84 mike            1.35  #include <Pegasus/Common/Config.h>
  85 kumpf           1.59  #include <Pegasus/Common/Constants.h>
  86 jim.wunderlich  1.172 #include <Pegasus/Common/PegasusAssert.h>
  87 mike            1.32  #include <cstdlib>
  88                       #include <Pegasus/Common/FileSystem.h>
  89 mike            1.35  #include <Pegasus/Common/Monitor.h>
  90 mike            1.32  #include <Pegasus/Common/PegasusVersion.h>
  91                       #include <Pegasus/Common/Logger.h>
  92                       #include <Pegasus/Common/System.h>
  93 mike            1.35  #include <Pegasus/Common/Tracer.h>
  94 kumpf           1.174 #include <Pegasus/Common/LanguageParser.h>
  95 mike            1.35  #include <Pegasus/Config/ConfigManager.h>
  96                       #include <Pegasus/Client/CIMClient.h>
  97                       #include <Pegasus/Server/ShutdownService.h>
  98 h.sterling      1.153 #include <Pegasus/Server/CIMServer.h>
  99                       #include <Service/ServerProcess.h>
 100 mike            1.32  
 101 chuck           1.155 #if defined(PEGASUS_OS_OS400)
 102                       #  include "vfyptrs.cinc"
 103                       #  include "OS400ConvertChar.h"
 104                       #endif
 105                       
 106 thilo.boehm     1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) 
 107                       #include <Service/ARM_zOS.h>
 108 marek           1.186 # ifdef PEGASUS_ZOS_SECURITY
 109                       // This include file will not be provided in the OpenGroup CVS for now.
 110                       // Do NOT try to include it in your compile
 111                       #  include <Pegasus/Common/safCheckzOS_inline.h>
 112                       # endif
 113 thilo.boehm     1.185 #endif
 114                       
 115 kumpf           1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
 116                       # if defined(PEGASUS_OS_OS400)
 117 mateus.baur     1.175 #  include <unistd.cleinc>
 118 kumpf           1.178 # else
 119 mateus.baur     1.175 #  include <unistd.h>
 120 kumpf           1.178 # endif
 121                       # include <sys/types.h>
 122                       # include <sys/stat.h>
 123                       # include <fcntl.h>
 124 mateus.baur     1.175 #endif
 125                       
 126 kumpf           1.119 PEGASUS_USING_PEGASUS;
 127                       PEGASUS_USING_STD;
 128                       
 129 h.sterling      1.153 #define PEGASUS_PROCESS_NAME "cimserver";
 130 mike            1.32  
 131 h.sterling      1.153 //Windows service variables are not defined elsewhere in the product
 132                       //enable ability to override these
 133                       #ifndef PEGASUS_SERVICE_NAME
 134                       #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
 135 chuck           1.66  #endif
 136 h.sterling      1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
 137                       #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
 138 mike            1.32  #endif
 139                       
 140 h.sterling      1.153 class CIMServerProcess : public ServerProcess
 141                       {
 142                       public:
 143                       
 144                           CIMServerProcess(void)
 145                           {
 146                               cimserver_set_process(this);
 147                           }
 148                       
 149                           virtual ~CIMServerProcess(void)
 150                           {
 151                           }
 152                       
 153                           //defined in PegasusVersion.h
 154                           virtual const char* getProductName() const
 155                           {
 156                               return PEGASUS_PRODUCT_NAME;
 157                           }
 158                       
 159                           virtual const char* getExtendedName() const
 160                           {
 161 h.sterling      1.153         return PEGASUS_SERVICE_NAME;
 162                           }
 163                       
 164                           virtual const char* getDescription() const
 165                           {
 166                               return PEGASUS_SERVICE_DESCRIPTION;
 167                           }
 168 david.dillard   1.165 
 169 h.sterling      1.153     //defined in PegasusVersion.h
 170 jim.wunderlich  1.180     virtual const char* getCompleteVersion() const
 171                           {
 172 jim.wunderlich  1.181       if (*PEGASUS_PRODUCT_STATUS == '\0' )
 173 jim.wunderlich  1.180 	return PEGASUS_PRODUCT_VERSION;
 174                             else
 175                       	return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;      
 176                           }
 177                       
 178                           //defined in PegasusVersion.h
 179 h.sterling      1.153     virtual const char* getVersion() const
 180                           {
 181                               return PEGASUS_PRODUCT_VERSION;
 182                           }
 183                       
 184                           virtual const char* getProcessName() const
 185                           {
 186                               return PEGASUS_PROCESS_NAME;
 187                           }
 188                       
 189 kumpf           1.184     //defined in Constants.h
 190 h.sterling      1.153     virtual const char* getPIDFileName() const
 191                           {
 192 kumpf           1.184         return PEGASUS_CIMSERVER_START_FILE;
 193 h.sterling      1.153     }
 194                       
 195 kumpf           1.178     int cimserver_run(
 196                               int argc,
 197                               char** argv,
 198                               Boolean shutdownOption,
 199                               Boolean debugOutputOption);
 200 h.sterling      1.153 
 201                           void cimserver_stop(void);
 202                       };
 203                       
 204                       AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
 205                       static CIMServer* _cimServer = 0;
 206 konrad.r        1.163 static Monitor* _monitor = 0;
 207 konrad.r        1.166 static Thread* dummyInitialThread = 0;
 208 mike            1.35  //
 209                       //  The command name.
 210                       //
 211                       static const char COMMAND_NAME []    = "cimserver";
 212                       
 213                       //
 214                       //  The constant defining usage string.
 215                       //
 216                       static const char USAGE []           = "Usage: ";
 217                       
 218                       /**
 219                       Constants representing the command line options.
 220                       */
 221                       static const char OPTION_VERSION     = 'v';
 222                       
 223                       static const char OPTION_HELP        = 'h';
 224                       
 225                       static const char OPTION_HOME        = 'D';
 226                       
 227                       static const char OPTION_SHUTDOWN    = 's';
 228                       
 229 a.arora         1.142 static const char   LONG_HELP []  = "help";
 230                       
 231                       static const char   LONG_VERSION []  = "version";
 232                       
 233 kumpf           1.178 static const char OPTION_DEBUGOUTPUT = 'X';
 234 kumpf           1.48  
 235 kumpf           1.54  static const String PROPERTY_TIMEOUT = "shutdownTimeout";
 236 mike            1.35  
 237                       ConfigManager*    configManager;
 238                       
 239 mike            1.32  /** GetOptions function - This function defines the Options Table
 240 mike            1.35      and sets up the options from that table using the config manager.
 241 mike            1.32  */
 242                       void GetOptions(
 243 mike            1.35      ConfigManager* cm,
 244 mike            1.32      int& argc,
 245 s.hills         1.117     char** argv)
 246 mike            1.32  {
 247 mike            1.35      try
 248 mike            1.32      {
 249 kumpf           1.38          cm->mergeConfigFiles();
 250 mike            1.33  
 251 mike            1.35          cm->mergeCommandLine(argc, argv);
 252                           }
 253 kumpf           1.122     catch (NoSuchFile&)
 254 mike            1.35      {
 255 kumpf           1.122         throw;
 256 mike            1.35      }
 257 kumpf           1.122     catch (FileNotReadable&)
 258 mike            1.35      {
 259 kumpf           1.122         throw;
 260 mike            1.35      }
 261 kumpf           1.122     catch (CannotRenameFile&)
 262 mike            1.35      {
 263 kumpf           1.122         throw;
 264 mike            1.35      }
 265 kumpf           1.122     catch (ConfigFileSyntaxError&)
 266 mike            1.35      {
 267 kumpf           1.122         throw;
 268 mike            1.35      }
 269 kumpf           1.122     catch(UnrecognizedConfigProperty&)
 270 mike            1.35      {
 271 kumpf           1.122         throw;
 272 mike            1.35      }
 273 kumpf           1.122     catch(InvalidPropertyValue&)
 274 mike            1.35      {
 275 kumpf           1.122         throw;
 276 mike            1.35      }
 277 kumpf           1.123     catch (CannotOpenFile&)
 278                           {
 279                               throw;
 280                           }
 281 mike            1.32  }
 282                       
 283                       /* PrintHelp - This is temporary until we expand the options manager to allow
 284                          options help to be defined with the OptionRow entries and presented from
 285                          those entries.
 286                       */
 287                       void PrintHelp(const char* arg0)
 288                       {
 289 mike            1.35      String usage = String (USAGE);
 290                           usage.append (COMMAND_NAME);
 291                           usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
 292                           usage.append ("  options\n");
 293 a.arora         1.142     usage.append ("    -v, --version   - displays CIM Server version number\n");
 294                           usage.append ("    -h, --help      - prints this help message\n");
 295 humberto        1.97      usage.append ("    -s              - shuts down CIM Server\n");
 296 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 297                           usage.append ("    -D [home]       - sets pegasus home directory\n");
 298 humberto        1.97  #endif
 299                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
 300 joyce.j         1.148     usage.append ("    -install [name] - installs pegasus as a Windows Service\n");
 301 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 302                           usage.append ("                      default CIM Server Service Name\n");
 303 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 304 joyce.j         1.148     usage.append ("    -remove [name]  - removes pegasus as a Windows Service\n");
 305 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 306                           usage.append ("                      default CIM Server Service Name\n");
 307 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 308 joyce.j         1.148     usage.append ("    -start [name]   - starts pegasus as a Windows Service\n");
 309 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 310                           usage.append ("                      default CIM Server Service Name\n");
 311 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 312 joyce.j         1.148     usage.append ("    -stop [name]    - stops pegasus as a Windows Service\n");
 313 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 314 aruran.ms       1.183     usage.append ("                      default CIM Server Service Name\n");
 315                           usage.append ("                      by appending [name]\n\n");
 316 humberto        1.97  #endif
 317                           usage.append ("  configProperty=value\n");
 318                           usage.append ("                    - sets CIM Server configuration property\n");
 319                       
 320                           cout << endl;
 321 jim.wunderlich  1.180     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
 322 humberto        1.97      cout << endl;
 323 david.dillard   1.165 
 324 humberto        1.97  #if defined(PEGASUS_OS_TYPE_WINDOWS)
 325 humberto        1.104     MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
 326 kumpf           1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
 327 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.HPUXLINUXIA64GNU", usage);
 328 humberto        1.97  #else
 329 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
 330 humberto        1.97  #endif
 331                           cout << MessageLoader::getMessage(parms) << endl;
 332 mike            1.35  }
 333                       
 334 h.sterling      1.156 //This needs to be called at various points in the code depending on the platform and error conditions.
 335                       //We need to delete the _cimServer reference on exit in order for the destructors to get called.
 336                       void deleteCIMServer()
 337                       {
 338                           if (_cimServer)
 339                           {
 340                               delete _cimServer;
 341                               _cimServer = 0;
 342 carolann.graves 1.171 
 343                       #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
 344                       || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
 345                       || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
 346                               //
 347                               //  Remove the PID file to indicate CIMServer termination
 348                               //
 349                               FileSystem::removeFile(_cimServerProcess->getPIDFileName());
 350                       #endif
 351 h.sterling      1.156     }
 352 kumpf           1.182     delete _monitor;
 353 konrad.r        1.166    if (dummyInitialThread)
 354                          {
 355                       	Thread::clearLanguages();
 356                       	delete dummyInitialThread;
 357                          }
 358 h.sterling      1.156 }
 359                       
 360 chuck           1.96  // l10n
 361                       //
 362                       // Dummy function for the Thread object associated with the initial thread.
 363                       // Since the initial thread is used to process CIM requests, this is
 364                       // needed to localize the exceptions thrown during CIM request processing.
 365 david.dillard   1.165 // Note: This function should never be called!
 366                       //
 367 mike            1.188 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void *parm)
 368 chuck           1.96  {
 369 mike            1.188    return((ThreadReturnType)0);
 370 chuck           1.96  }
 371                       
 372 carolann.graves 1.171 //
 373                       //  Waits until either the CIM Server has terminated, or the shutdown timeout
 374                       //  has expired.  If the shutdown timeout has expired, and the CIM Server is
 375                       //  still running, kills the cimserver process.
 376                       //
 377                       void _waitForTerminationOrTimeout (Uint32 maxWaitTime)
 378                       {
 379                           //
 380                           //  If the CIM Server is still running, and the shutdown timeout has not
 381                           //  expired, loop and wait one second until either the CIM Server has
 382                           //  terminated, or the shutdown timeout has expired
 383                           //
 384                           Boolean running = _cimServerProcess->isCIMServerRunning ();
 385                           while (running && (maxWaitTime > 0))
 386                           {
 387                               System::sleep (1);
 388                               running = _cimServerProcess->isCIMServerRunning ();
 389                               maxWaitTime--;
 390                           }
 391                       
 392                           //
 393 carolann.graves 1.171     //  If the shutdown timeout has expired, and the CIM Server is still
 394                           //  running, kill the cimserver process
 395                           //
 396                           if (running)
 397                           {
 398                               int kill_rc = _cimServerProcess->cimserver_kill (0);
 399                       
 400                       #ifdef PEGASUS_OS_OS400
 401                               if (kill_rc == -1)
 402                               {
 403                                   _cimServerProcess->cimserver_exitRC (2);
 404                               }
 405                               _cimServerProcess->cimserver_exitRC (1);
 406                       #endif
 407                       
 408                       #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
 409                       || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_SOLARIS) \
 410                       || defined (PEGASUS_OS_VMS)
 411                               if (kill_rc != -1)
 412                               {
 413                                   //l10n - TODO
 414 carolann.graves 1.171             Logger::put_l (Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 415                                       "src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
 416                                       "Shutdown timeout expired.  Forced shutdown initiated.");
 417                                   MessageLoaderParms parms
 418                                       ("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
 419                                       "Shutdown timeout expired.  Forced shutdown initiated.");
 420                                   cout << MessageLoader::getMessage(parms) << endl;
 421                                   exit (0);
 422                               }
 423                       #endif
 424                           }
 425                       }
 426                       
 427 kumpf           1.52  void shutdownCIMOM(Uint32 timeoutValue)
 428 mike            1.35  {
 429                           //
 430                           // Create CIMClient object
 431                           //
 432 kumpf           1.42      CIMClient client;
 433 mike            1.35  
 434                           //
 435 kumpf           1.53      // Get local host name
 436 mike            1.35      //
 437                           String hostStr = System::getHostName();
 438                       
 439                           //
 440 david.dillard   1.165     // open connection to CIMOM
 441 mike            1.35      //
 442                           try
 443                           {
 444 kumpf           1.43          client.connectLocal();
 445 kumpf           1.52  
 446                               //
 447 kumpf           1.63          // set client timeout to 2 seconds
 448 kumpf           1.52          //
 449 kumpf           1.71          client.setTimeout(2000);
 450 mike            1.35      }
 451 s.hills         1.117     catch(Exception&)
 452 mike            1.35      {
 453 david           1.85  #ifdef PEGASUS_OS_OS400
 454 h.sterling      1.153     //l10n
 455                           //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 456                                   //"Unable to connect to CIM Server.  CIM Server may not be running." );
 457                           Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 458                                   "src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
 459                                   "Unable to connect to CIM Server.  CIM Server may not be running." );
 460                           // The server job may still be active but not responding.
 461                           // Kill the job if it exists.
 462                           if(_cimServerProcess->cimserver_kill(0) == -1)
 463                              _cimServerProcess->cimserver_exitRC(2);
 464                           _cimServerProcess->cimserver_exitRC(1);
 465 david           1.85  #else
 466 humberto        1.97          //l10n
 467                               //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);
 468                               //PEGASUS_STD(cerr) << "CIM Server may not be running." << PEGASUS_STD(endl);
 469                               MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
 470 kumpf           1.105                                                          "Unable to connect to CIM Server.\nCIM Server may not be running.\n");
 471 humberto        1.97          PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
 472 s.hills         1.117         exit(1);
 473 chuck           1.66  #endif
 474 mike            1.35      }
 475                       
 476                           try
 477                           {
 478                               //
 479 kumpf           1.52          // construct CIMObjectPath
 480 mike            1.35          //
 481                               String referenceStr = "//";
 482                               referenceStr.append(hostStr);
 483 david.dillard   1.165         referenceStr.append("/");
 484 kumpf           1.72          referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString());
 485 kumpf           1.53          referenceStr.append(":");
 486 kumpf           1.72          referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString());
 487 kumpf           1.50          CIMObjectPath reference(referenceStr);
 488 mike            1.35  
 489                               //
 490                               // issue the invokeMethod request on the shutdown method
 491                               //
 492                               Array<CIMParamValue> inParams;
 493                               Array<CIMParamValue> outParams;
 494                       
 495 kumpf           1.52          // set force option to true for now
 496 kumpf           1.40          inParams.append(CIMParamValue("force",
 497 kumpf           1.52              CIMValue(Boolean(true))));
 498 mike            1.35  
 499 kumpf           1.40          inParams.append(CIMParamValue("timeout",
 500 kumpf           1.39              CIMValue(Uint32(timeoutValue))));
 501 mike            1.35  
 502                               CIMValue retValue = client.invokeMethod(
 503 kumpf           1.59              PEGASUS_NAMESPACENAME_SHUTDOWN,
 504 mike            1.35              reference,
 505                                   "shutdown",
 506                                   inParams,
 507                                   outParams);
 508 kumpf           1.43      }
 509 kumpf           1.65      catch(CIMException& e)
 510 kumpf           1.46      {
 511 david           1.85  #ifdef PEGASUS_OS_OS400
 512                       
 513 h.sterling      1.153     if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
 514                           {
 515                               //l10n
 516                               //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 517                                   //"Failed to shutdown server: $0", "The repository may be empty.");
 518                               Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 519                                   "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
 520                                   "Error in server shutdown: The repository may be empty.");
 521                           }
 522                           else
 523                           {
 524                               //l10n
 525                               //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 526                                   //"Failed to shutdown server: $0", e.getMessage());
 527                               Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 528                                   "src.Server.cimserver.SHUTDOWN_FAILED",
 529                                   "Error in server shutdown: $0", e.getMessage());
 530                           }
 531                           // Kill the server job.
 532                           if(_cimServerProcess->cimserver_kill(0) == -1)
 533                              _cimServerProcess->cimserver_exitRC(2);
 534 david           1.85  #else
 535 kumpf           1.105         //l10n - TODO
 536 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",
 537 kumpf           1.105                                  "Error in server shutdown: ");
 538 humberto        1.97          PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
 539 kumpf           1.63          if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
 540                               {
 541 kumpf           1.105             //
 542 david.dillard   1.165             // Repository may be empty.
 543 kumpf           1.105             //
 544                                   //l10n - TODO
 545                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 546                                       "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
 547                                       "Error in server shutdown: The repository may be empty.");
 548 humberto        1.97              MessageLoaderParms parms("src.Server.cimserver.REPOSITORY_EMPTY",
 549 kumpf           1.105                                      "The repository may be empty.");
 550                                   PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
 551 kumpf           1.63          }
 552                               else
 553                               {
 554 kumpf           1.105             //l10n - TODO
 555                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 556                                       "src.Server.cimserver.SHUTDOWN_FAILED",
 557                                       "Error in server shutdown: $0", e.getMessage());
 558 kumpf           1.63              PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl);
 559                               }
 560 kumpf           1.105 
 561 david.dillard   1.165     // Kill the cimserver process
 562 h.sterling      1.153     if (_cimServerProcess->cimserver_kill(0) == 0)
 563 kumpf           1.105         {
 564                                   //l10n - TODO
 565                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 566                                       "src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
 567 h.sterling      1.153             "Forced shutdown initiated.");
 568 kumpf           1.105             MessageLoaderParms parms("src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
 569                                                            "Forced shutdown initiated.");
 570                                   PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
 571                               }
 572 s.hills         1.117         exit(1);
 573 chuck           1.66  #endif
 574 kumpf           1.46      }
 575 s.hills         1.117     catch(Exception&)
 576 kumpf           1.45      {
 577                               //
 578 kumpf           1.91          // This may mean that the CIM Server has terminated, causing this
 579                               // client to get a "Empty HTTP response message" exception.  It may
 580 david.dillard   1.165         // also mean that the CIM Server is taking longer than 2 seconds
 581                               // (client timeout value) to terminate, causing this client to
 582 kumpf           1.91          // timeout with a "connection timeout" exception.
 583 kumpf           1.45          //
 584 carolann.graves 1.171         //  Wait until either the CIM Server has terminated, or the shutdown
 585                               //  timeout has expired.  If the timeout has expired and the CIM Server
 586                               //  is still running, kill the cimserver process.
 587                               //
 588                               _waitForTerminationOrTimeout (timeoutValue - 2);
 589 kumpf           1.168     }
 590                       
 591 carolann.graves 1.171     //
 592                           //  InvokeMethod succeeded.
 593                           //  Wait until either the CIM Server has terminated, or the shutdown
 594                           //  timeout has expired.  If the timeout has expired and the CIM Server
 595                           //  is still running, kill the cimserver process.
 596                           //
 597                           _waitForTerminationOrTimeout (timeoutValue);
 598 mike            1.35      return;
 599 mike            1.32  }
 600                       
 601 mike            1.35  
 602 mike            1.33  /////////////////////////////////////////////////////////////////////////
 603 mike            1.32  //  MAIN
 604                       //////////////////////////////////////////////////////////////////////////
 605                       int main(int argc, char** argv)
 606                       {
 607 mike            1.35      String pegasusHome  = String::EMPTY;
 608                           Boolean shutdownOption = false;
 609 kumpf           1.178     Boolean debugOutputOption = false;
 610 mday            1.47  
 611 humberto        1.97  //l10n
 612                       // Set Message loading to process locale
 613 david.dillard   1.165 MessageLoader::_useProcessLocale = true;
 614 humberto        1.97  //l10n
 615                       
 616 kv.le           1.140 //l10n
 617                       #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
 618                       setlocale(LC_ALL, "");
 619                       #endif
 620                       
 621 chuck           1.66  #ifdef PEGASUS_OS_OS400
 622 david           1.120 
 623                         VFYPTRS_INCDCL;               // VFYPTRS local variables
 624                       
 625                         // verify pointers
 626                         #pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\
 627                           0,_C2_MH_ESCAPE)
 628                           for( int arg_index = 1; arg_index < argc; arg_index++ ){
 629 h.sterling      1.153     VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));
 630 david           1.120     }
 631                         #pragma disable_handler
 632                       
 633 david           1.100     // Convert the args to ASCII
 634                           for(Uint32 i = 0;i< argc;++i)
 635                           {
 636 h.sterling      1.153     EtoA(argv[i]);
 637 david           1.100     }
 638                       
 639 chuck           1.66      // Initialize Pegasus home to the shipped OS/400 directory.
 640                           pegasusHome = OS400_DEFAULT_PEGASUS_HOME;
 641                       #endif
 642                       
 643 kv.le           1.134 
 644 tony            1.82  #ifndef PEGASUS_OS_TYPE_WINDOWS
 645 kumpf           1.38      //
 646                           // Get environment variables:
 647                           //
 648 david           1.100 #ifdef PEGASUS_OS_OS400
 649                       #pragma convert(37)
 650                           const char* tmp = getenv("PEGASUS_HOME");
 651                       #pragma convert(0)
 652                           char home[256] = {0};
 653                           if (tmp && strlen(tmp) < 256)
 654                           {
 655 h.sterling      1.153     strcpy(home, tmp);
 656                           EtoA(home);
 657                           pegasusHome = home;
 658 david           1.100     }
 659                       #else
 660 kv.le           1.134   #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
 661                           pegasusHome = AIX_RELEASE_PEGASUS_HOME;
 662 marek           1.170   #elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 663 kumpf           1.38      const char* tmp = getenv("PEGASUS_HOME");
 664                       
 665                           if (tmp)
 666                           {
 667                               pegasusHome = tmp;
 668                           }
 669 kv.le           1.134   #endif
 670 david           1.100 #endif
 671 kumpf           1.38  
 672                           FileSystem::translateSlashes(pegasusHome);
 673 tony            1.82  #else
 674 kumpf           1.38  
 675 tony            1.82    // windows only
 676 h.sterling      1.153   //setHome(pegasusHome);
 677                         pegasusHome = _cimServerProcess->getHome();
 678 tony            1.82  #endif
 679 mike            1.32  
 680 kumpf           1.60          // Get help, version, and shutdown options
 681 mike            1.35  
 682                               for (int i = 1; i < argc; )
 683                               {
 684                                   const char* arg = argv[i];
 685 a.arora         1.142             if(String::equal(arg,"--help"))
 686                                   {
 687                                           PrintHelp(argv[0]);
 688                                           exit(0);
 689                                   }
 690                                   else if(String::equal(arg,"--version"))
 691                                   {
 692 jim.wunderlich  1.180                 cout << _cimServerProcess->getCompleteVersion() << endl;
 693 a.arora         1.142                 exit(0);
 694                                   }
 695 mike            1.35              // Check for -option
 696 a.arora         1.142             else if (*arg == '-')
 697 mike            1.35              {
 698                                       // Get the option
 699                                       const char* option = arg + 1;
 700                       
 701                                       //
 702                                       // Check to see if user asked for the version (-v option):
 703                                       //
 704 tony            1.83                  if (*option == OPTION_VERSION &&
 705                                           strlen(option) == 1)
 706 mike            1.35                  {
 707 jim.wunderlich  1.180                     cout << _cimServerProcess->getCompleteVersion() << endl;
 708 mike            1.35                      exit(0);
 709                                       }
 710                                       //
 711                                       // Check to see if user asked for help (-h option):
 712                                       //
 713 tony            1.83                  else if (*option == OPTION_HELP &&
 714                                               (strlen(option) == 1))
 715 mike            1.35                  {
 716                                           PrintHelp(argv[0]);
 717                                           exit(0);
 718                                       }
 719 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 720 tony            1.83                  else if (*option == OPTION_HOME &&
 721                                               (strlen(option) == 1))
 722 mike            1.35                  {
 723 kumpf           1.60                      if (i + 1 < argc)
 724 mike            1.35                      {
 725                                               pegasusHome.assign(argv[i + 1]);
 726                                           }
 727                                           else
 728                                           {
 729 humberto        1.97                          //l10n
 730                                               //cout << "Missing argument for option -" << option << endl;
 731 humberto        1.99                          String opt(option);
 732 humberto        1.97                          MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",
 733 h.sterling      1.153                                          "Missing argument for option -$0",
 734                                                                opt);
 735                                               cout << MessageLoader::getMessage(parms) << endl;
 736 mike            1.35                          exit(0);
 737                                           }
 738                       
 739                                           memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
 740                                           argc -= 2;
 741                                       }
 742 kumpf           1.63  #endif
 743 kumpf           1.48                  //
 744 kumpf           1.178                 // Check to see if user asked for debug output (-X option):
 745 kumpf           1.48                  //
 746 kumpf           1.178                 else if (*option == OPTION_DEBUGOUTPUT &&
 747 tony            1.83                          (strlen(option) == 1))
 748 kumpf           1.48                  {
 749 kumpf           1.178                     MessageLoaderParms parms(
 750                                               "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
 751                                               "Unsupported debug output option is enabled.");
 752 h.sterling      1.153                     cout << MessageLoader::getMessage(parms) << endl;
 753 kumpf           1.178 
 754                                           debugOutputOption = true;
 755                       
 756                       #if defined(PEGASUS_OS_HPUX)
 757                                           System::bindVerbose = true;
 758                       #endif
 759                       
 760 kumpf           1.48                      // remove the option from the command line
 761                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 762 david.dillard   1.165                     argc--;
 763 kumpf           1.48                  }
 764 mike            1.35                  //
 765                                       // Check to see if user asked for shutdown (-s option):
 766                                       //
 767 tony            1.82                  else if (*option == OPTION_SHUTDOWN &&
 768                                               (strlen(option) == 1))
 769 mike            1.35                  {
 770                                           //
 771 kumpf           1.52                      // Check to see if shutdown has already been specified:
 772 mike            1.35                      //
 773 kumpf           1.52                      if (shutdownOption)
 774 mike            1.35                      {
 775 humberto        1.97                          //l10n
 776                                               //cout << "Duplicate shutdown option specified." << endl;
 777                                               MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
 778 h.sterling      1.153                                                  "Duplicate shutdown option specified.");
 779 david.dillard   1.165 
 780 humberto        1.97                          cout << MessageLoader::getMessage(parms) << endl;
 781 mike            1.35                          exit(0);
 782                                           }
 783                       
 784 kumpf           1.52                      shutdownOption = true;
 785 david.dillard   1.165 
 786 mike            1.35                      // remove the option from the command line
 787                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 788 david.dillard   1.165                     argc--;
 789 mike            1.35                  }
 790                                       else
 791                                           i++;
 792                                   }
 793                                   else
 794                                       i++;
 795 mike            1.32          }
 796 mike            1.35  
 797 kumpf           1.38      //
 798                           // Set the value for pegasusHome property
 799                           //
 800                           ConfigManager::setPegasusHome(pegasusHome);
 801 mike            1.32  
 802 mike            1.35      //
 803 carolann.graves 1.171     // Do the platform specific run
 804 s.hills         1.117     //
 805                       
 806 kumpf           1.178     return _cimServerProcess->platform_run(
 807                               argc, argv, shutdownOption, debugOutputOption);
 808 s.hills         1.117 }
 809                       
 810 h.sterling      1.153 void CIMServerProcess::cimserver_stop()
 811                       {
 812                           _cimServer->shutdownSignal();
 813                       }
 814 s.hills         1.117 
 815                       //
 816                       // The main, common, running code
 817                       //
 818 david.dillard   1.165 // NOTE: Do NOT call exit().  Use return(), otherwise some platforms
 819 s.hills         1.117 // will fail to shutdown properly/cleanly.
 820                       //
 821 david.dillard   1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
 822 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
 823 david.dillard   1.165 // daemon stuff into platform specific platform_run(), etc.
 824                       // Note: make sure to not put error handling stuff that platform
 825 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
 826 s.hills         1.117 //
 827                       
 828 kumpf           1.178 int CIMServerProcess::cimserver_run(
 829                           int argc,
 830                           char** argv,
 831                           Boolean shutdownOption,
 832                           Boolean debugOutputOption)
 833 s.hills         1.117 {
 834                           String logsDirectory = String::EMPTY;
 835                           Boolean daemonOption = false;
 836                       
 837                           //
 838 mike            1.35      // Get an instance of the Config Manager.
 839                           //
 840                           configManager = ConfigManager::getInstance();
 841 kumpf           1.136     configManager->useConfigFiles = true;
 842 mike            1.35  
 843 lucier          1.130 #ifdef PEGASUS_OS_OS400
 844                           // In a special startup case for IBM OS400, when the server is
 845                           // automatically started when the machine starts up the config
 846                           // file cannot be read because of access restrictions for the
 847                           // user starting the server.  In this case, we need to skip
 848                           // reading the config options and therefore any use of the config
 849                           // manager also.  To make this determinations we will check to see
 850                           // if the daemon flag is set to true.  If so, then there will be a
 851                           // series of checks to bracket all the calls to the configManager
 852                           // which would otherwise fail.  All this will only be done for
 853                           // IBM OS400.
 854                       
 855                           Boolean os400StartupOption = false;
 856                           // loop through args to check for daemon=true
 857                           for (int i=1; i < argc; i++)
 858                             if (strcmp(argv[i], "daemon=true") == 0)
 859                             {
 860                               os400StartupOption = true;
 861                               daemonOption = true;
 862                             }
 863 chuck           1.164 
 864                           if (!os400StartupOption)
 865                           {
 866                               // If this is the server job, then set the job
 867                               // to save the job log.
 868                               system ("QSYS/CHGJOB JOB(*) LOG(4 00 *SECLVL)");
 869                           }
 870 david.dillard   1.165 #endif
 871 lucier          1.130 
 872 mike            1.35      //
 873 mike            1.32      // Get options (from command line and from configuration file); this
 874 mike            1.35      // removes corresponding options and their arguments from the command
 875 mike            1.32      // line.
 876 mike            1.35      //
 877 mike            1.32      try
 878                           {
 879 lucier          1.130 #ifdef PEGASUS_OS_OS400
 880                           if (os400StartupOption == false)
 881 david.dillard   1.165 #endif
 882 s.hills         1.117         GetOptions(configManager, argc, argv);
 883 mike            1.32      }
 884                           catch (Exception& e)
 885                           {
 886 kumpf           1.127         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 887                                   "src.Server.cimserver.SERVER_NOT_STARTED",
 888                                   "cimserver not started:  $0", e.getMessage());
 889                       
 890                       #if !defined(PEGASUS_OS_OS400)
 891                               MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 892                                   "cimserver not started: $0", e.getMessage());
 893                       
 894                               PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
 895                                   << PEGASUS_STD(endl);
 896 david           1.85  #endif
 897 kumpf           1.127 
 898 s.hills         1.117         return(1);
 899 mike            1.32      }
 900                       
 901 chuck           1.94  // l10n
 902 h.sterling      1.153     // Set the home directory, msg sub-dir, into the MessageLoader.
 903 david.dillard   1.165     // This will be the default directory where the resource bundles
 904                           // are found.
 905 h.sterling      1.153     MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
 906 david.dillard   1.165         ConfigManager::getInstance()->getCurrentValue("messageDir")));
 907 chuck           1.94  
 908 lucier          1.130 #ifdef PEGASUS_OS_OS400
 909                           // Still need to declare and set the connection variables.
 910                           // Will initialize to false since they are fixed at false for OS400.
 911                       
 912                           // NOTE:  OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down
 913                           // the test will not be compiled in.  If OS400 ever turns off that
 914                           // define, then we will need to change this code path to insure that
 915 david.dillard   1.165     // one of the variables is true.
 916 lucier          1.130     Boolean enableHttpConnection = false;
 917                           Boolean enableHttpsConnection = false;
 918                       
 919                           if (os400StartupOption == false)
 920                           {
 921 kumpf           1.187       enableHttpConnection = ConfigManager::parseBooleanValue(
 922                                 configManager->getCurrentValue("enableHttpConnection"));
 923                             enableHttpsConnection = ConfigManager::parseBooleanValue(
 924                                 configManager->getCurrentValue("enableHttpsConnection"));
 925 lucier          1.130     }
 926                       #else
 927 kumpf           1.187     Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 928                               configManager->getCurrentValue("enableHttpConnection"));
 929                           Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 930                               configManager->getCurrentValue("enableHttpsConnection"));
 931 lucier          1.130 #endif
 932 kumpf           1.86  
 933                           // Make sure at least one connection is enabled
 934 h.sterling      1.159 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 935 kumpf           1.86      if (!enableHttpConnection && !enableHttpsConnection)
 936                           {
 937 humberto        1.97          //l10n
 938                               //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 939                                   //"Neither HTTP nor HTTPS connection is enabled.  "
 940                                   //"CIMServer will not be started.");
 941                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 942 h.sterling      1.153             "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 943 humberto        1.97              "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");
 944                               //cerr << "Neither HTTP nor HTTPS connection is enabled.  "
 945                                   //"CIMServer will not be started." << endl;
 946                               MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 947 h.sterling      1.153                                  "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");
 948 humberto        1.97          cerr << MessageLoader::getMessage(parms) << endl;
 949 s.hills         1.117         return(1);
 950 kumpf           1.86      }
 951                       #endif
 952                       
 953 mike            1.35      try
 954 mike            1.32      {
 955 mike            1.35          //
 956 kumpf           1.187         // Check to see if we should start Pegasus as a daemon
 957 mike            1.35          //
 958                       
 959 kumpf           1.187         daemonOption = ConfigManager::parseBooleanValue(
 960                                   configManager->getCurrentValue("daemon"));
 961 david.dillard   1.165 
 962 lucier          1.130 #ifdef PEGASUS_OS_OS400
 963                           if (os400StartupOption == false)
 964                           {
 965 david.dillard   1.165 #endif
 966 kumpf           1.36          // Get the log file directory definition.
 967                               // We put String into Cstring because
 968                               // Directory functions only handle Cstring.
 969                               // ATTN-KS: create String based directory functions.
 970 konrad.r        1.161 #if !defined(PEGASUS_USE_SYSLOGS)
 971                       		// When using syslog facility. No files anymore.
 972 kumpf           1.36          logsDirectory = configManager->getCurrentValue("logdir");
 973 david.dillard   1.165         logsDirectory =
 974 h.sterling      1.153         ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
 975 konrad.r        1.161 #endif
 976 lucier          1.130 #ifdef PEGASUS_OS_OS400
 977                           }  // end if (os400StartupOption == false)
 978                       #endif
 979 kumpf           1.36  
 980                               // Set up the Logger. This does not open the logs
 981                               // Might be more logical to clean before set.
 982                               // ATTN: Need tool to completely disable logging.
 983                       
 984 david           1.85  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
 985 konrad.r        1.161 !defined(PEGASUS_OS_OS400) && !defined(PEGASUS_USE_SYSLOGS)
 986 kumpf           1.36          Logger::setHomeDirectory(logsDirectory);
 987 kumpf           1.57  #endif
 988 kumpf           1.36  
 989                               //
 990 david.dillard   1.165         // Check to see if we need to shutdown CIMOM
 991 mike            1.35          //
 992                               if (shutdownOption)
 993                               {
 994 david.dillard   1.165             String configTimeout =
 995 kumpf           1.60                  configManager->getCurrentValue("shutdownTimeout");
 996 s.hills         1.117             Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
 997 dave.sudlik     1.191 // To deregister Pegasus with SLP
 998                       #ifdef PEGASUS_SLP_REG_TIMEOUT
 999                                   unregisterPegasusFromSLP();
1000                       #endif
1001 david.dillard   1.165 
1002 kumpf           1.52              shutdownCIMOM(timeoutValue);
1003 kumpf           1.45  
1004 david           1.85  #ifdef PEGASUS_OS_OS400
1005 h.sterling      1.153         //l10n
1006                               //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
1007 david.dillard   1.165             //"CIM Server stopped.");
1008 h.sterling      1.153         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
1009                                   "src.Server.cimserver.SERVER_STOPPED",
1010                                   "CIM Server stopped.");
1011 s.hills         1.117             cimserver_exitRC(0);
1012 david           1.85  #else
1013 h.sterling      1.153             //l10n
1014 humberto        1.97              //cout << "CIM Server stopped." << endl;
1015                                   MessageLoaderParms parms("src.Server.cimserver.SERVER_STOPPED",
1016 h.sterling      1.153                                      "CIM Server stopped.");
1017 humberto        1.106 
1018 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
1019 s.hills         1.117             return(0);
1020 diane           1.81  #endif
1021 mike            1.35          }
1022 mike            1.32  
1023 kumpf           1.139 #if defined(PEGASUS_DEBUG)
1024 kumpf           1.36          // Leave this in until people get familiar with the logs.
1025 humberto        1.97          //l10n
1026                               //cout << "Logs Directory = " << logsDirectory << endl;
1027 konrad.r        1.161 #if !defined(PEGASUS_USE_SYSLOGS)
1028 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
1029 h.sterling      1.153                                  "Logs Directory = ");
1030 humberto        1.97          cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
1031 kumpf           1.57  #endif
1032 konrad.r        1.161 #endif
1033 mike            1.32      }
1034 kumpf           1.122     catch (UnrecognizedConfigProperty& e)
1035 mike            1.32      {
1036 marek           1.186         // UnrecognizedConfigProperty is already translated
1037                               // thus, just output the message
1038                               Logger::put(Logger::ERROR_LOG,
1039                                           System::CIMSERVER,
1040                                           Logger::SEVERE,
1041                                           e.getMessage());
1042                       #ifndef PEGASUS_OS_OS400
1043                               cout << e.getMessage() << endl;
1044                       #endif
1045                           }
1046                           catch (Exception& ex)
1047                           {
1048                               Logger::put(Logger::ERROR_LOG,
1049                                             System::CIMSERVER,
1050                                             Logger::SEVERE,
1051                                             ex.getMessage());
1052                       #ifndef PEGASUS_OS_OS400
1053                               cout << ex.getMessage() << endl;
1054                       #endif
1055                               exit(1);
1056                           }
1057 david           1.85  
1058 marek           1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
1059                           startupCheckBPXServer(true);
1060                           startupCheckProfileCIMSERVclassWBEM();
1061                           startupEnableMSC();
1062 david           1.85  #endif
1063 mike            1.32  
1064 h.sterling      1.158     // Bug 2148 - Here is the order of operations for determining the server HTTP and HTTPS ports.
1065                           // 1) If the user explicitly specified a port, use it.
1066                           // 2) If the user did not specify a port, get the port from the services file.
1067                           // 3) If no value is specified in the services file, use the IANA WBEM default port.
1068                           // Note that 2 and 3 are done within the System::lookupPort method
1069                           // An empty string from the ConfigManager implies that the user did not specify a port.
1070                       
1071 w.otsuka        1.147     Uint32 portNumberHttps=0;
1072                           Uint32 portNumberHttp=0;
1073                           Uint32 portNumberExportHttps=0;
1074 kumpf           1.53  
1075 kumpf           1.86      if (enableHttpsConnection)
1076 kumpf           1.53      {
1077 kumpf           1.86          String httpsPort = configManager->getCurrentValue("httpsPort");
1078 h.sterling      1.158         if (httpsPort == String::EMPTY)
1079 joyce.j         1.144         {
1080 h.sterling      1.158             //
1081                                   // Look up the WBEM-HTTPS port number
1082                                   //
1083                                   portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1084                       
1085                               } else
1086 david.dillard   1.165         {
1087 h.sterling      1.158             //
1088                                   // user-specified
1089                                   //
1090                                   CString portString = httpsPort.getCString();
1091                                   char* end = 0;
1092                                   portNumberHttps = strtol(portString, &end, 10);
1093                                   if(!(end != 0 && *end == '\0'))
1094                                   {
1095 joyce.j         1.160                 InvalidPropertyValue e("httpsPort", httpsPort);
1096 aruran.ms       1.173                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1097                                                     "src.Server.cimserver.SERVER_NOT_STARTED",
1098                                                     "cimserver not started:  $0", e.getMessage());
1099                       #if !defined(PEGASUS_OS_OS400)
1100                                       MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1101                                                                "cimserver not started: $0", e.getMessage());
1102                                       PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
1103                                                         << PEGASUS_STD(endl);
1104                       #endif
1105 h.sterling      1.158                 exit(1);
1106                                   }
1107 joyce.j         1.144         }
1108 kumpf           1.53      }
1109 kumpf           1.86  
1110                           if (enableHttpConnection)
1111 kumpf           1.53      {
1112 kumpf           1.86          String httpPort = configManager->getCurrentValue("httpPort");
1113 h.sterling      1.158         if (httpPort == String::EMPTY)
1114 joyce.j         1.144         {
1115 h.sterling      1.158             //
1116                                   // Look up the WBEM-HTTP port number
1117                                   //
1118                                   portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1119                       
1120                               } else
1121                               {
1122                                   //
1123                                   // user-specified
1124                                   //
1125                                   CString portString = httpPort.getCString();
1126                                   char* end = 0;
1127                                   portNumberHttp = strtol(portString, &end, 10);
1128                                   if(!(end != 0 && *end == '\0'))
1129                                   {
1130 joyce.j         1.160                 InvalidPropertyValue e("httpPort", httpPort);
1131 aruran.ms       1.173                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1132                                                     "src.Server.cimserver.SERVER_NOT_STARTED",
1133                                                     "cimserver not started:  $0", e.getMessage());
1134                       #if !defined(PEGASUS_OS_OS400)
1135                                       MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1136                                                                    "cimserver not started: $0", e.getMessage());
1137                                       PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
1138                                                         << PEGASUS_STD(endl);
1139                       #endif
1140 h.sterling      1.158                 exit(1);
1141                                   }
1142 joyce.j         1.144         }
1143 kumpf           1.53      }
1144 kumpf           1.139 #if defined(PEGASUS_DEBUG)
1145 mike            1.32      // Put out startup up message.
1146 jim.wunderlich  1.180     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
1147 humberto        1.97      //l10n
1148                           //cout << "Built " << __DATE__ << " " << __TIME__ << endl;
1149                           //cout <<"Starting..."
1150                           MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
1151 h.sterling      1.153                              "Built $0 $1\nStarting...",
1152                                                    __DATE__,
1153                                                    __TIME__);
1154 humberto        1.97  #endif
1155                       
1156                       //l10n
1157                       // reset message loading to NON-process locale
1158 david.dillard   1.165 MessageLoader::_useProcessLocale = false;
1159 humberto        1.97  //l10n
1160 mike            1.32  
1161 kumpf           1.137     // Get the parent's PID before forking
1162 h.sterling      1.154     _cimServerProcess->set_parent_pid(System::getPID());
1163 david.dillard   1.165 
1164 kumpf           1.63      // do we need to run as a daemon ?
1165                           if (daemonOption)
1166                           {
1167 h.sterling      1.153         if(-1 == _cimServerProcess->cimserver_fork())
1168 diane           1.81  #ifndef PEGASUS_OS_OS400
1169 h.sterling      1.153     {
1170                               return(-1);
1171                           }
1172 diane           1.81  #else
1173 h.sterling      1.153     {
1174 david           1.85              return(-1);
1175 h.sterling      1.153     }
1176                           else
1177                           {
1178                               return(0);
1179                           }
1180 diane           1.81  #endif
1181 david.dillard   1.165 
1182 kumpf           1.63      }
1183 chuck           1.66  
1184 chuck           1.96  // l10n
1185                           // Now we are after the fork...
1186                           // Create a dummy Thread object that can be used to store the
1187 kumpf           1.176     // AcceptLanguageList object for CIM requests that are serviced
1188 chuck           1.96      // by this thread (initial thread of server).  Need to do this
1189                           // because this thread is not in a ThreadPool, but is used
1190                           // to service CIM requests.
1191                           // The run function for the dummy Thread should never be called,
1192 konrad.r        1.166     dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
1193 david.dillard   1.165     Thread::setCurrent(dummyInitialThread);
1194 kumpf           1.176     AcceptLanguageList default_al;
1195 humberto        1.108     try{
1196 kumpf           1.174          default_al = LanguageParser::getDefaultAcceptLanguages();
1197 kumpf           1.176          Thread::setLanguages(new AcceptLanguageList(default_al));
1198 kumpf           1.122     }catch(InvalidAcceptLanguageHeader& e){
1199 h.sterling      1.153           Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1200                                         "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
1201 david.dillard   1.165                   "Could not convert the system process locale into a valid AcceptLanguage format.");
1202 h.sterling      1.153           Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1203 david.dillard   1.165                              e.getMessage());
1204 humberto        1.108     }
1205 david.dillard   1.165 
1206                       
1207 chuck           1.96  
1208 chuck           1.66  #ifdef PEGASUS_OS_OS400
1209                           // Special server initialization code for OS/400.
1210                           if (cimserver_initialize() != 0)
1211                           {
1212 h.sterling      1.153     // do some logging here!
1213                           //l10n
1214                           //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1215 david.dillard   1.165             //"CIM Server failed to initialize");
1216 h.sterling      1.153     Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1217                                         "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",
1218 david.dillard   1.165                   "CIM Server failed to initialize");
1219 h.sterling      1.153     return(-1);
1220 david.dillard   1.165     }
1221 chuck           1.66  #endif
1222 chuck           1.96  
1223 kumpf           1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
1224                           umask(S_IRWXG|S_IRWXO);
1225                       #endif
1226 mday            1.62  
1227 mateus.baur     1.175 
1228                       #if defined(PEGASUS_OS_TYPE_UNIX)
1229                         //    
1230                         // CRITICAL SECTION BEGIN
1231                         //
1232                         // This is the beginning of the critical section regarding the
1233                         // access to pidfile (file to indicate that the cimserver has started).
1234                         // Sometimes, when 2 or more cimserver processes are started at the same 
1235                         // time, they can't detect the concurrent process execution because the 
1236                         // logic fails when pidfile is accessed concurrently.
1237                       
1238                         FILE *startupLockFile;
1239                       
1240 denise.eckstein 1.177   if ((startupLockFile = fopen(ConfigManager::getHomedPath(
1241                                 CIMSERVER_LOCK_FILE).getCString(), "w")) != 0)
1242 mateus.baur     1.175   {
1243                             lockf(fileno(startupLockFile), F_LOCK, 0);
1244                         }
1245                       #endif
1246                       
1247 gs.keenan       1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
1248                       || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
1249 jim.wunderlich  1.169 || defined(PEGASUS_OS_SOLARIS) || defined (PEGASUS_OS_VMS)
1250 kumpf           1.79  
1251                           //
1252                           // check if CIMServer is already running
1253 david.dillard   1.165     // if CIMServer is already running, print message and
1254 kumpf           1.79      // notify parent process (if there is a parent process) to terminate
1255                           //
1256 h.sterling      1.153     if(_cimServerProcess->isCIMServerRunning())
1257 kumpf           1.79      {
1258 h.sterling      1.153     //l10n
1259                               //cout << "Unable to start CIMServer." << endl;
1260                               //cout << "CIMServer is already running." << endl;
1261                               MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
1262 thilo.boehm     1.192                      "Unable to start CIMServer. CIMServer is already running.");
1263 h.sterling      1.153     PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
1264 thilo.boehm     1.192         Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
1265                                           MessageLoader::getMessage(parms));
1266 kumpf           1.79  
1267 h.sterling      1.153     //
1268 kumpf           1.79          // notify parent process (if there is a parent process) to terminate
1269                               //
1270                               if (daemonOption)
1271 h.sterling      1.153                 _cimServerProcess->notify_parent(1);
1272 kumpf           1.79  
1273 s.hills         1.117         return(1);
1274 kumpf           1.79      }
1275 david.dillard   1.165 
1276 kumpf           1.63  #endif
1277 kumpf           1.51  
1278 mike            1.32      // try loop to bind the address, and run the server
1279                           try
1280                           {
1281 mday            1.116 
1282 konrad.r        1.163     _monitor  = new Monitor();
1283 h.sterling      1.153     //PEP#222
1284                           //CIMServer server(&monitor);
1285                           //CimserverHolder cimserverHolder( &server );
1286 konrad.r        1.163     _cimServer = new CIMServer(_monitor);
1287 mday            1.111 
1288 kumpf           1.41  
1289 kumpf           1.86          if (enableHttpConnection)
1290                               {
1291 sushma.fernandes 1.189             _cimServer->addAcceptor(false, portNumberHttp, false);
1292 humberto         1.97              //l10n
1293                                    //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1294                                                //"Listening on HTTP port $0.", portNumberHttp);
1295 david.dillard    1.165 
1296 humberto         1.97              Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1297 h.sterling       1.153                             "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1298                                                    "Listening on HTTP port $0.", portNumberHttp);
1299 kumpf            1.86          }
1300                                if (enableHttpsConnection)
1301                                {
1302 sushma.fernandes 1.189             _cimServer->addAcceptor(false, portNumberHttps, true);
1303 humberto         1.97              //l10n
1304                                    //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1305                                                //"Listening on HTTPS port $0.", portNumberHttps);
1306                                    Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1307 h.sterling       1.153                             "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1308                                                    "Listening on HTTPS port $0.", portNumberHttps);
1309 kumpf            1.86          }
1310 kumpf            1.135 
1311 h.sterling       1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1312 sushma.fernandes 1.189         _cimServer->addAcceptor(true, 0, false);
1313 humberto         1.97          //l10n
1314                                //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1315                                            //"Listening on local connection socket.");
1316                                Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1317 h.sterling       1.153               "src.Server.cimserver.LISTENING_ON_LOCAL",
1318                                      "Listening on local connection socket.");
1319 kumpf            1.41  #endif
1320 kumpf            1.86  
1321 kumpf            1.139 #if defined(PEGASUS_DEBUG)
1322 kumpf            1.86          if (enableHttpConnection)
1323                                {
1324 humberto         1.97              //l10n
1325                                    //cout << "Listening on HTTP port " << portNumberHttp << endl;
1326 h.sterling       1.153       MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1327                                           "Listening on HTTP port $0.", portNumberHttp);
1328                                    cout << MessageLoader::getMessage(parms) << endl;
1329 kumpf            1.86          }
1330                                if (enableHttpsConnection)
1331                                {
1332 humberto         1.97              //l10n
1333                                    //cout << "Listening on HTTPS port " << portNumberHttps << endl;
1334 humberto         1.103             MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1335 h.sterling       1.153                      "Listening on HTTPS port $0.", portNumberHttps);
1336                                    cout << MessageLoader::getMessage(parms) << endl;
1337 kumpf            1.86          }
1338 kumpf            1.135 
1339 h.sterling       1.159 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1340 humberto         1.97          //l10n
1341                                //cout << "Listening on local connection socket" << endl;
1342                                MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_LOCAL",
1343 h.sterling       1.153                  "Listening on local connection socket.");
1344 humberto         1.97          cout << MessageLoader::getMessage(parms) << endl;
1345 kumpf            1.86  # endif
1346 david            1.85  #endif
1347 mike             1.35  
1348 kumpf            1.86          // bind throws an exception if the bind fails
1349 david.dillard    1.165 	try {
1350 konrad.r         1.163            _cimServer->bind();
1351                        	} catch (const BindFailedException &e)
1352                        	{
1353                        #ifdef PEGASUS_DEBUG
1354                                MessageLoaderParms parms("src.Server.cimserver.BIND_FAILED",
1355                                         "Could not bind: $0.", e.getMessage());
1356                                cout << MessageLoader::getMessage(parms) << endl;
1357                        #endif
1358                                Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1359                                    "src.Server.cimserver.BIND.FAILED",
1360                                    "Could not bind:  $0", e.getMessage());
1361 kumpf            1.73  
1362 konrad.r         1.163 	   deleteCIMServer();
1363                        	   return 1;
1364                        	}
1365 david.dillard    1.165     // notify parent process (if there is a parent process) to terminate
1366 konrad.r         1.95          // so user knows that there is cimserver ready to serve CIM requests.
1367 h.sterling       1.153     if (daemonOption)
1368                                _cimServerProcess->notify_parent(0);
1369 mike             1.32  
1370 h.sterling       1.153     time_t last = 0;
1371 mike             1.35  
1372 gs.keenan        1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) \
1373 jim.wunderlich   1.169     || defined(PEGASUS_OS_AIX) || defined(PEGASUS_OS_SOLARIS) \
1374 gs.keenan        1.150     || defined(PEGASUS_OS_VMS)
1375 kumpf            1.45          //
1376 kumpf            1.56          // create a file to indicate that the cimserver has started and
1377                                // save the process id of the cimserver process in the file
1378 kumpf            1.45          //
1379 kumpf            1.56          // remove the old file if it exists
1380 h.sterling       1.153         System::removeFile(_cimServerProcess->getPIDFileName());
1381 kumpf            1.56  
1382                                // open the file
1383 h.sterling       1.153         FILE *pid_file = fopen(_cimServerProcess->getPIDFileName(), "w");
1384 kumpf            1.91  
1385 kumpf            1.56          if (pid_file)
1386 kumpf            1.45          {
1387 kumpf            1.56              // save the pid in the file
1388 h.sterling       1.153             fprintf(pid_file, "%ld\n", _cimServerProcess->get_server_pid());
1389 kumpf            1.56              fclose(pid_file);
1390 kumpf            1.45          }
1391                        #endif
1392 kumpf            1.91  
1393 kumpf            1.139 #if defined(PEGASUS_DEBUG)
1394 h.sterling       1.153     cout << "Started. " << endl;
1395 kumpf            1.63  #endif
1396 david.dillard    1.165 
1397 mateus.baur      1.175 #if defined(PEGASUS_OS_TYPE_UNIX)    
1398                            //
1399                            // CRITICAL SECTION END
1400                            // 
1401                            // Here is the unlock of file 'lock_file'. It closes the
1402                            // the critical section that guarantees the non concurrent access to
1403                            // pid file (file to indicate that the cimserver has started).
1404                            //
1405                        
1406                            if (startupLockFile)
1407                            {
1408                               lockf(fileno(startupLockFile), F_ULOCK, 0);
1409                               fclose(startupLockFile);
1410                            }
1411                        #endif
1412                        
1413                        
1414 kumpf            1.54          // Put server started message to the logger
1415 kumpf            1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1416                                    Logger::INFORMATION,
1417                                    "src.Server.cimserver.STARTED_VERSION",
1418                                    "Started $0 version $1.",
1419 jim.wunderlich   1.180 		      _cimServerProcess->getProductName(), _cimServerProcess->getCompleteVersion());
1420 kumpf            1.45  
1421 marek            1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1422 kumpf            1.178         if (daemonOption && !debugOutputOption)
1423                                { 
1424                                    // Direct standard input, output, and error to /dev/null,
1425                                    // since we are running as a daemon.
1426                                    close(0);
1427                                    open("/dev/null", O_RDONLY);
1428                                    close(1);
1429                                    open("/dev/null", O_RDWR);
1430                                    close(2);
1431                                    open("/dev/null", O_RDWR);
1432                                }
1433                        #endif
1434                        
1435 thilo.boehm      1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1436                        
1437                                // ARM is a z/OS internal restart facility. 
1438                                // This is a z/OS specific change. 
1439                        
1440                                // Instatiating the automatic restart manager for zOS
1441                                ARM_zOS automaticRestartManager;
1442                        
1443                                // register to zOS ARM
1444                                automaticRestartManager.Register();
1445                        
1446                        #endif
1447                        
1448                        
1449                        
1450 mike             1.35          //
1451                                // Loop to call CIMServer's runForever() method until CIMServer
1452                                // has been shutdown
1453                                //
1454 h.sterling       1.153     while( !_cimServer->terminated() )
1455                            {
1456 mday             1.116 
1457 h.sterling       1.153       _cimServer->runForever();
1458 mday             1.112 
1459 h.sterling       1.153     }
1460 carson.hovey     1.157 
1461 kumpf            1.45          //
1462                                // normal termination
1463 carson.hovey     1.157         //
1464 thilo.boehm      1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1465                        
1466                                // ARM is a z/OS internal restart facility. 
1467                                // This is a z/OS specific change. 
1468                        
1469                                // register to zOS ARM
1470                                automaticRestartManager.DeRegister();
1471                        
1472                        #endif
1473 kumpf            1.143 
1474 kumpf            1.54          // Put server shutdown message to the logger
1475 kumpf            1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1476                                    Logger::INFORMATION, "src.Server.cimserver.STOPPED",
1477 h.sterling       1.153             "$0 stopped.", _cimServerProcess->getProductName());
1478 kumpf            1.45  
1479 carolann.graves  1.171 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
1480 gs.keenan        1.150 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
1481 jim.wunderlich   1.169 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
1482 kumpf            1.45          //
1483 carolann.graves  1.171         //  Note: do not remove the PID file created at startup time, since
1484                                //  shutdown is not complete until the CIMServer destructor completes.
1485 kumpf            1.45          //
1486                        #endif
1487 mike             1.32      }
1488                            catch(Exception& e)
1489                            {
1490 david            1.100 
1491 h.sterling       1.153     //l10n
1492                            //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1493 david.dillard    1.165             //"Error: $0", e.getMessage());
1494 h.sterling       1.153     Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1495                                    "src.Server.cimserver.ERROR",
1496 david.dillard    1.165             "Error: $0", e.getMessage());
1497 konrad.r         1.95  
1498                        #ifndef PEGASUS_OS_OS400
1499 h.sterling       1.153     //l10n
1500                            //PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
1501                            MessageLoaderParms parms("src.Server.cimserver.ERROR",
1502                                                     "Error: $0", e.getMessage());
1503                            PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
1504 david            1.100 
1505 david            1.85  #endif
1506 kumpf            1.77  
1507 h.sterling       1.153     //
1508 kumpf            1.77          // notify parent process (if there is a parent process) to terminate
1509                                //
1510                                if (daemonOption)
1511 h.sterling       1.153                 _cimServerProcess->notify_parent(1);
1512 kumpf            1.77  
1513 h.sterling       1.156         deleteCIMServer();
1514 kumpf            1.54          return 1;
1515 mike             1.32      }
1516                        
1517 h.sterling       1.156     deleteCIMServer();
1518 mike             1.32      return 0;
1519                        }
1520 tony             1.128 
1521                        
1522                        
1523                        

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2