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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2