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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2