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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2