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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2