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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2